Make pipeline execution policy variables take precedence
What does this MR do and why?
Variables defined in a pipeline execution policy will take the highest precedence. This MR makes it work for variables that are defined as part of a custom scan action
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- Create a group
- Go to Settings -> General
- Toggle the Permissions and group features section
- Enable Run customized CI YAML file as security policy actions
- Create a project
- Add a
.gitlab-ci.ymlfile containing a variable:variables: GLOBAL_VAR: "project setting" - Go to Secure -> Policies
- Select New policy
- Select Scan execution policy
- Switch to .yaml mode and paste the following policy:
type: scan_execution_policy name: Compliance description: '' enabled: true rules: - type: pipeline branch_type: all actions: - scan: custom ci_configuration: |- variables: GLOBAL_VAR: "policy" test policy job: stage: test script: - echo "'$GLOBAL_VAR'" - Select Configure with a merge request and merge the MR
- On the project page, Select Build -> Pipelines
- Select Run pipeline
- Add a variable with key:
GLOBAL_VARand value:web trigger - Inspect the test policy job logs. The printed variable should say "policy" and not "web trigger".
Related to #439237 (closed)
Edited by Andy Schoenen