2

I am unable to find a solution for how to ignore changes made in .gitlab-ci.yml to trigger a job. So far I have tried the below options:

except:
  changes:
  - .gitlab-ci.yml

and

only
 - Branch A

but every time i make changes in .gitlab.ci-yml file, jobs for Stage B get added in pipeline and show as skipped.

Below are the jobs defined in .gitlab-ci.yml. Do you have any suggestion here?

I do not want Stage B jobs get added in pipeline when:

i) push made against the .gitlab-ci.yml (either manual changing file or git push command)
ii) any merge request for .gitlab-ci.yml

stages:
 - A
 - B
 
Stage A:
  stage: A
  script:
    - echo "TEST"
  rules:
    - if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.DEV\d+/'
  tags:
    - runner
    
Stage B:
  stage: B
  script:
    - echo "TEST"
  when: manual
  tags:
    - runner
karel
  • 5,489
  • 46
  • 45
  • 50
Sushil.R
  • 97
  • 2
  • 11

2 Answers2

2

With this setup the Stage B is not added if .gitlab-ci.yml is modified:

stages:
 - A
 - B

Stage A:
  stage: A
  script:
    - echo "Stage A"
  tags:
    - runner

Stage B:
  stage: B
  script:
    - echo "Stage B"
  rules:
    - changes:
      - ".gitlab-ci.yml"
      when: never
    - when: manual
  tags:
   - runner

Otherwise Stage B is showed in the pipeline and can be run manually. Tested with GitLab CI CE 14.1.0.

Davide Madrisan
  • 1,969
  • 2
  • 14
  • 22
1

Could you try using workflow rule? It should determine if the pipeline is created.

P.S: Someone complained a couple of years ago about not being able to activate manual jobs after the exception, but it looks like it was a bug. I can't find the issue mentioned in the post

Edit:

This conf skips any commit with changes README.md or .gitlab-ci.yml:

workflow:
    rules:
        - if:
          changes: 
            - README.md
            - .gitlab-ci.yml
          when: never
Pelayo
  • 114
  • 5