Add CI Variable that points to API URL
Summary
When running ci pipeline jobs I often make calls to the gitlab api to further automate tasks. Things like triggering pipelines, creating commits, and creating MRs. It is frustrating that I always have to piece together the API URL of the server and project url.
Expectation
I expect gitlab to expose the following variables so I don't have to create them by hand or statically define them in secret variables or .gitlab-ci.yml.
Proposed new CI variables
- CI_GITLAB_API_BASE_URL
- CI_GITLAB_API_PROJECT_URL
Example variable values would look like:
CI_GITLAB_API_BASE_URL=https://gitlab.com/api/v4
CI_GITLAB_API_PROJECT_URL=https://gitlab.com/api/v4/projects/32324
Not sure if I need to mention this but gitlab.com would obviously be replaced with the actual hostname of the gitlab server. I am only using gitlab.com as an example.
Example Usage
trigger_build:
stage: deploy
script:
- "curl -X POST -F token=$TOKEN -F ref=master ${CI_GITLAB_API_BASE_URL}/projects/123456/trigger/pipeline"
Edited by Corey Osman