CI environment variables for project and namespace name
Description
CI jobs have access to several environment variables including information about the current project. These include:
-
CI_PROJECT_NAME
- The project name that is currently being built -
CI_PROJECT_NAMESPACE
- The project namespace (username or groupname) that is currently being built -
CI_PROJECT_PATH
- The namespace with project name -
CI_PROJECT_PATH_SLUG
-$CI_PROJECT_PATH
lowercased and with everything except 0-9 and a-z replaced with -. Use in URLs and domain names. -
CI_PROJECT_URL
- The HTTP address to access project
CI_PROJECT_NAME
and CI_PROJECT_NAMESPACE
are misleading - they provide the paths and not the names of the project and namespace. It is not currently possible to obtain these names from any environment variable.
Proposal
I propose that the project name and namespace name be made available as CI environment variables.
Over in issue gitlab-ce#32513 it was determined that the behavior of CI_PROJECT_NAME
is incorrect and that the name should be used instead of the path. I agree with this suggestion.
For the namespace, I would propose either:
- Changing
CI_PROJECT_NAMESPACE
to contain the name instead of the path; or, - Leaving
CI_PROJECT_NAMESPACE
as-is and creatingCI_PROJECT_NAMESPACE_NAME
to contain the name
Links / references
- https://docs.gitlab.com/ce/ci/variables/#predefined-variables-environment-variables
- Issue gitlab-ce#32513
Documentation blurb
Overview
This feature will provide CI jobs with the name
of the project and its namespace. These are currently unavailable to those jobs.
Use cases
One example use case would be notifying developers about builds passing or failing. For example, when GitLab CI deploys changes to a server, we have a custom script that sends a push notification to Slack:
Instead of using the path of sae/sae-itc-drupal7
, I'd like to be able to use the human-friendly namespace and project names which I don't currently have access to during the job which issues this push notification.
Feature checklist
Make sure these are completed before closing the issue, with a link to the relevant commit.
-
Feature assurance -
Documentation -
Added to features.yml