Set job source for Scan Execution Policy, Pipeline Execution Policy jobs
What does this MR do and why?
Utilizes the Ci::BuildSource
model to mark jobs that are created by Pipeline Execution Policy or Scan Execution Policy.
- Adds
pipeline_execution_policy
to the source enum inCi::BuildSource
- Adds
Ci::Build#source=
convenience method which builds thebuild_source
association and sets its source name and project id - Adds a new step in
CreatePipelineService
namedPopulateBuildSource
, which creates associated sources for PEP jobs (based on the job'sexecution_policy_job
option flag) and SEP jobs (based on the job name format) - Adds specs for above
Verification (local)
Pipeline Execution Policy jobs
- Select a project with a CI/CD configuration
- Under Secure > Policies on the left, create a new Pipeline Execution Policy with a working configuration (inject on the main project's .gitlab-ci.yml should work)
- Run a pipeline in the main project (some pipeline editing may be required)
- View the jobs created in the new pipeline
- In a Rails console, use
Ci::Build.find
to fetch the most recent jobs. Verify thatbuild.source
returns"pipeline_execution_policy"
- Verify that other jobs lower in the pipeline have a source value of
"push"
- the source of the pipeline itself - Verify the source records for jobs in step 5 were created using
Ci::BuildSource.find
Scan Execution Policy jobs
- Select a project with a CI/CD configuration
- Under Secure > Policies on the left, create a new Scan Execution Policy with a working configuration (e.g. trigger on changes to default branch)
- Trigger a pipeline in the main project
- View the jobs created in the new pipeline
- In a Rails console, use
Ci::Build.find
to fetch the scan-specific job based on the name. Verify thatbuild.source
returns"scan_execution_policy"
- Verify that other jobs in the pipeline have a source value of
"push"
- the source of the pipeline itself - Verify the source records for jobs in step 5 were created using
Ci::BuildSource.find
Related to #475140
Edited by Aaron Huntsman