Skip to content

Add error for cross pipeline dependencies

Laura Montemayor requested to merge lm-fix-pluck-config-entry-job into master

What does this MR do and why?

Fixes: undefined method 'pluck' for nil:NilClass: #349974 (closed)

This can happen in two scenarios (or more?), but they both happen when we have a config that uses the keyword dependencies.

Scenario 1 - if a dependency: job is from a job that is supposed to be in the same pipeline but is also referenced as a cross pipeline dependency (so we don't know what it is actually referring to):

jobA:
    script: echo "a"

jobB:
    script: echo "b"
    dependencies:
        - jobA
    needs:
        - job: jobA
          pipeline: other

Note: this can be fixed if the job: jobA is added to the needs

Scenario 2 - if a dependency: job is referring to a needs: job that is another pipeline.

jobA:
    script: echo "a"

jobB:
    script: echo "b"
    dependencies:
        - jobX
    needs:
        - job: jobX
          pipeline: other

In both cases, they should be using dependencies: job to refer to a job in the same pipeline.

The easiest way to validate this is by pasting the config above in the pipeline editor on main/master and with this branch.

Before After
Screen_Shot_2022-02-11_at_7.50.13_PM Screen_Shot_2022-02-11_at_7.52.36_PM
{"errors":[{"message":"Internal server error: undefined method pluck' for nil:NilClass"}]}` "data":{"ciConfig":{"errors":["jobs:jobb dependencies must be from the same pipeline"],"mergedYaml":"---\njobX:\n script: echo \"a\"\njobB:\n script: echo \"b\"\n dependencies:\n - jobA\n needs:\n - job: jobA\n pipeline: other\n","status":"INVALID","stages":null,"__typename":"CiConfig"}}}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Laura Montemayor

Merge request reports

Loading