Add support for CI_COMMIT_REF_NAME variable in includes
What does this MR do?
- Adds the ability to use the
$CI_COMMIT_REF_NAME
variable in aninclude
block in a CI pipeline.- This has the intended side-effect of adding support for merge requests that use compliance frameworks.
Screenshots or Screencasts (strongly suggested)
How to setup and validate locally (strongly suggested)
This is the instructions to set up the compliance-framework specific use-case. It can be used on its own though.
- Ultimate only feature
- Create a new group.
Set up compliance framework
- Within that group, a new project "ComplianceFrameworks".
- Create a file to hold the framework config:
.gitlab-compliance-ci.yml
stages:
- test
- build
compliance_job:
stage: build
script:
- echo "Performing compliance build steps"
include:
- file: '$CI_CONFIG_PATH' # .gitlab-ci.yml of
project: '$CI_PROJECT_PATH' # the project currently creating the pipeline
ref: '$CI_COMMIT_REF_NAME'
- In the group settings, create a new compliance framework. Call it whatever you like, and use the new file as the pipeline config.
Set up project
- In the same group, create a new project.
- In the project settings, set the compliance framework to be the framework created above.
- Create a gitlab CI configuration:
.gitlab-ci.yml
- Something like this...
stages:
- test
testing:
stage: test
script:
- echo "This is master"
Test it!
- Run a CI pipeline of
master
. It should work, and include the compliance pipeline. Note the output: "This is master". -
Edit
.gitlab-ci.yml
and update the script to output something different. - Commit that change to a different branch and create a merge request.
- Start a new pipeline for the newly created branch.
- Note the changed output in the CI log should match the change made.
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Security
Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Related to #331506 (closed)
Edited by Max Woolf