Skip to content

Set job source for Scan Execution Policy, Pipeline Execution Policy jobs

Aaron Huntsman requested to merge ahuntsman/set_pep_job_source into master

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 in Ci::BuildSource
  • Adds Ci::Build#source= convenience method which builds the build_source association and sets its source name and project id
  • Adds a new step in CreatePipelineService named PopulateBuildSource, which creates associated sources for PEP jobs (based on the job's execution_policy_job option flag) and SEP jobs (based on the job name format)
  • Adds specs for above

Verification (local)

Pipeline Execution Policy jobs

  1. Select a project with a CI/CD configuration
  2. 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)
  3. Run a pipeline in the main project (some pipeline editing may be required)
  4. View the jobs created in the new pipeline
  5. In a Rails console, use Ci::Build.find to fetch the most recent jobs. Verify that build.source returns "pipeline_execution_policy"
  6. Verify that other jobs lower in the pipeline have a source value of "push" - the source of the pipeline itself
  7. Verify the source records for jobs in step 5 were created using Ci::BuildSource.find

Scan Execution Policy jobs

  1. Select a project with a CI/CD configuration
  2. Under Secure > Policies on the left, create a new Scan Execution Policy with a working configuration (e.g. trigger on changes to default branch)
  3. Trigger a pipeline in the main project
  4. View the jobs created in the new pipeline
  5. In a Rails console, use Ci::Build.find to fetch the scan-specific job based on the name. Verify that build.source returns "scan_execution_policy"
  6. Verify that other jobs in the pipeline have a source value of "push" - the source of the pipeline itself
  7. Verify the source records for jobs in step 5 were created using Ci::BuildSource.find

Related to #475140

Edited by Aaron Huntsman

Merge request reports

Loading