diff --git a/app/models/project.rb b/app/models/project.rb index 446329557d5a71117079726201e623673323ec6b..36bc7659bb2bfa2189c1374e8f44c74834298db6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1226,6 +1226,7 @@ class Project < ActiveRecord::Base { key: 'CI_PROJECT_ID', value: id.to_s, public: true }, { key: 'CI_PROJECT_NAME', value: path, public: true }, { key: 'CI_PROJECT_PATH', value: path_with_namespace, public: true }, + { key: 'CI_PROJECT_PATH_SLUG', value: path_with_namespace.parameterize, public: true }, { key: 'CI_PROJECT_NAMESPACE', value: namespace.full_path, public: true }, { key: 'CI_PROJECT_URL', value: web_url, public: true } ] diff --git a/changelogs/unreleased/31061-26135-ci-project-slug-enviroment-variables.yml b/changelogs/unreleased/31061-26135-ci-project-slug-enviroment-variables.yml new file mode 100644 index 0000000000000000000000000000000000000000..e71910dbd67d42433e1fea7c03c99a7cb9ec56aa --- /dev/null +++ b/changelogs/unreleased/31061-26135-ci-project-slug-enviroment-variables.yml @@ -0,0 +1,4 @@ +--- +title: Add slugify project path to CI enviroment variables +merge_request: 11838 +author: Ivan Chernov diff --git a/doc/ci/variables/README.md b/doc/ci/variables/README.md index 76ad7c564a3494b7153b4b4a98763ab32c104fb8..ad897d5cf1ac22dbff954274b2495b9566495fa9 100644 --- a/doc/ci/variables/README.md +++ b/doc/ci/variables/README.md @@ -56,9 +56,10 @@ future GitLab releases.** | **CI_PIPELINE_TRIGGERED** | all | all | The flag to indicate that job was [triggered] | | **CI_PROJECT_DIR** | all | all | The full path where the repository is cloned and where the job is run | | **CI_PROJECT_ID** | all | all | The unique id of the current project that GitLab CI uses internally | -| **CI_PROJECT_NAME** | 8.10 | 0.5 | The project name that is currently being built | +| **CI_PROJECT_NAME** | 8.10 | 0.5 | The project name that is currently being built (actually it is project folder name) | | **CI_PROJECT_NAMESPACE** | 8.10 | 0.5 | The project namespace (username or groupname) that is currently being built | | **CI_PROJECT_PATH** | 8.10 | 0.5 | The namespace with project name | +| **CI_PROJECT_PATH_SLUG** | 9.3 | all | `$CI_PROJECT_PATH` lowercased and with everything except `0-9` and `a-z` replaced with `-`. Use in URLs and domain names. | | **CI_PROJECT_URL** | 8.10 | 0.5 | The HTTP address to access project | | **CI_REGISTRY** | 8.10 | 0.5 | If the Container Registry is enabled it returns the address of GitLab's Container Registry | | **CI_REGISTRY_IMAGE** | 8.10 | 0.5 | If the Container Registry is enabled for the project it returns the address of the registry tied to the specific project | diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index e2406290c6c2e2cadff5c63cc1ccc68e4e0ced4e..55bfeb6eb418f927bdbb6ae174f747b3f18cf9d1 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1139,6 +1139,7 @@ describe Ci::Build, :models do { key: 'CI_PROJECT_ID', value: project.id.to_s, public: true }, { key: 'CI_PROJECT_NAME', value: project.path, public: true }, { key: 'CI_PROJECT_PATH', value: project.full_path, public: true }, + { key: 'CI_PROJECT_PATH_SLUG', value: project.full_path.parameterize, public: true }, { key: 'CI_PROJECT_NAMESPACE', value: project.namespace.full_path, public: true }, { key: 'CI_PROJECT_URL', value: project.web_url, public: true }, { key: 'CI_PIPELINE_ID', value: pipeline.id.to_s, public: true },