`rules:needs: []` does not override job's `needs`

Hello,

I am trying to reset a job’s needs using rules:needs: [].
The documentation says that it should “sets the job needs to none” (c.f. the documentation of rules:needs).

However, it does not appear to be working as explained in the documentation, the job needs are not setted to none.

I am using a public repository on gitlab.com (so not self managed), with the runners of gitlab (not self managed either).

Here is the .gitlab-ci.yaml I used to test this :

stages: 
    - prepare
    - test

needed job:
    stage: prepare
    rules:
        -   when: manual
        -   when: on_success
    script:
        - echo "ok"

# when the pipeline is launched, this job should be runnable manually, but it does not seems to be (the job is waiting for the previous needed one)
override needs in rule ([]):
    stage: test
    needs:
        - job: needed job
    rules:
        -   when: manual
            needs: []
        -   when: on_success
    script:
        - echo "ok"

# trying to use null instead of [] gives the same results
override needs in rule (null):
    stage: test
    needs:
        - job: needed job
    rules:
        -   when: manual
            needs: null
        -   when: on_success
    script:
        - echo "ok"

# overriding with a non-existing job seems to give the expected result (i.e. the job can be runned manually, and is not waiting for the previously needed job)
override needs in rule (non existing job):
    stage: test
    needs:
        - job: needed job
    rules:
        -   when: manual
            needs: 
                - job: non-existing-job
                  optional: true
        -   when: on_success
    script:
        - echo "ok"

Any idea why this is happening ?
I’m posting here before opening an issue on gitlab repository, to be sure it is an unreported bug.
Thanks.

2 Likes