Skip to content

Fix error when security policy CI contains no jobs

What does this MR do and why?

This fixes an error that appears if a custom security policy CI does not define any jobs

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. Create a new Group.
  2. Navigate to Settings -> General.
  3. Expand the Permissions and group features section.
  4. Enable the "Run customized CI YAML file as security policy actions" experiment.
  5. Create a new project in the group.
  6. Add a .gitlab-ci.yml file with content:
    job1:
      stage: build
      script:
        - echo "job 1"
  7. Select Secure -> Policies -> New policy .
  8. Select Scan execution policy.
  9. Switch to .yaml mode and past the following policy:
    type: scan_execution_policy
    name: test
    description: ''
    enabled: true
    rules:
      - type: pipeline
        branch_type: all
    actions:
      - scan: custom
        ci_configuration: |-
          variables:
            GLOBAL_VAR: "Policies"
    
  10. Select configure with a merge request and merge the MR.
  11. Start a new pipeline in the project.
  12. Starting the pipeline should work without an error.

Merge request reports