Skip to content

Ensure .pipeline-policy-pre jobs finish before starting others

What does this MR do and why?

Jobs with empty needs statements can start at any time even if other pipeline stages are not finished yet. For the .pipeline-policy-pre stage we want to make an exception to ensure security policy jobs can not be bypassed and have to finish before other stages.

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

  1. Enable the feature flag: echo "Feature.enable(:ensure_pipeline_policy_pre_stage_complete)" | rails c
  2. Create a project with a CI jobs using needs: []:
    project job:
      stage: test
      needs: []
      script:
        - echo "Project CI script"
    
  3. Create another file for the pipeline execution policy CI config:
    # policy-ci.yml
    pipeline execution policy job:
      stage: .pipeline-policy-pre
      script:
        - sleep 200
        - echo "Enforce your policy here"
  4. On the left sidebar, select Security & Compliance and Policies.
  5. Select New Policy
  6. Select Pipeline execution policy
  7. Choose a name for the policy
  8. In the Actions section, choose Inject and select the project and policy-ci.yml file you created in step 3.
  9. Select Update via Merge Request.
  10. Merge the MR.
  11. Start a pipeline on the project
  12. The project job should stay in the created state until the pipeline execution policy job is done.

Related to #469256 (closed)

Edited by Andy Schoenen

Merge request reports

Loading