Skip to content

Policy Job ignores needs order when dependent from parallel matrix

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Steps to reproduce

  1. In a Top-Level group, create a Pipeline Execution Policy and include a policy project, like the following:
pipeline_execution_policy:
  - name: test_policy_v1
    description: ''
    enabled: true
    policy_scope:
      projects:
        excluding: []
    pipeline_config_strategy: inject_policy
    content:
      include:
        - project: asalii_ultimate_group/policy_v1
          ref: main
          file: policy_v1.yml
    suffix: never
    variables_override:
      allowed: false
      exceptions: []
  1. In policy_v1.yml , create a job with needs dependency:
policy_job:
   script: echo "policy_job runs"
   needs:
     - job: "dependency-job"
       artifacts: true
       optional: true
  1. Under the group, create a project with .gitlab-ci.yml with a parallel:matrix job:
dependency-job:
    stage: build
    script:
        - echo "this is my test job"
        - sleep 120
   
     parallel:
       matrix:
         - PROVIDER: aws
         - PROVIDER: gcc
  1. Start a pipeline

What is the current bug behavior?

The pipeline UI shows job relations via needs , but the dependent job starts earlier

Screenshot 2025-10-15 at 12.54.22.png

What is the expected correct behavior?

The dependent via needs job should wait for jobs in needs dependency to finish and generate artifacts.

Two conditions are important:

  1. needs relation should be added by a Policy job
  2. The job in needs should have parallel:matrix

When the dependency job is not a parallel:matrix, the jobs order works as intended.

If the needs relation is set in the project's job and not set by a Policy job, the relation works as intended.

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

  (For installations with omnibus-gitlab package run and paste the output of: \\\`sudo gitlab-rake gitlab:env:info\\\`)  (For installations from source run and paste the output of: \\\`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production\\\`)   

Results of GitLab application Check

Expand for output related to the GitLab application check

 (For installations with omnibus-gitlab package run and paste the output of: \`sudo gitlab-rake gitlab:check SANITIZE=true\`)  (For installations from source run and paste the output of: \`sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true\`)  (we will only investigate if the tests are passing)  

Possible fixes

Patch release information for backports

If the bug fix needs to be backported in a patch release to a version under the maintenance policy, please follow the steps on the patch release runbook for GitLab engineers.

Refer to the internal "Release Information" dashboard for information about the next patch release, including the targeted versions, expected release date, and current status.

High-severity bug remediation

To remediate high-severity issues requiring an internal release for single-tenant SaaS instances, refer to the internal release process for engineers.

Edited by 🤖 GitLab Bot 🤖