How to skip the pipeline from job Gitlab

Put together a small test project.

I want in the pipeline:

  1. update package version.
  2. publish the package in npm.
  3. commit and push the changes by skipping the next pipe.

But I ran into such a problem that if I run command git push --push-option="ci.skip" locally, the pipeline is skipped. If I launch a push from a job, the next pipeline is not skipped

The git version is 2.11.0 in the job, so you need to use the command git push --push-option="ci.skip"

What am I doing wrong?

.gitlab-ci.yml

image: node@sha256:1163a6593bdc407eadb6412aa065393e01135aed67a48a35e3b04182d230e64e

stages:
  - hello
  - update

hello-stage:
  stage: hello
  script: 
    - echo 'Hello World'

update-version:
  stage: update
  when: manual
  script: 
    - echo 'Update version with yarn 2'
    - yarn version check
    - yarn version apply
    - git config --global user.name "$GITLAB_USER_NAME"
    - git config --global user.email "$GITLAB_USER_EMAIL"
    - git remote set-url origin "https://gitlab-ci-token:$GIT_PUSH_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git"
    - git --version # 2.11.0
    - git add .
    - git commit -m 'update package' 
    - npm publish
    - git push --push-option='ci.skip' origin HEAD:master # result pipeline not skipped

Result

The pipe is launched to my commit, at 2 stages the package version is updated in the job, commit and push.

Then the pipeline starts again, although it seems to be skipped

Hi,

with using a specifically crafted commit message, you can define rules in jobs to determine whether to execute them.

  rules:
    - if $CI_COMMIT_MESSAGE =~ /skip ci/
      when: manual
      allow_failure: true

Similar to what this blog post explains: https://www.cqse.eu/en/news/blog/skipping-tests-gitlab-ci/

Maybe this is a possible solution in your pipeline steps.

Cheers,
Michael

If you place [ci skip] in the commit message, then the pipeline is skipped. But then, by hand, the pipeline cannot be launched through the “Run pipeline” button. You need to make a new commit without [ci skip]

1 Like

I faced same problem,did you solved it?

While was in the same situation, I figured out that you can always run the whole pipeline from a branch and it will skip the skip mark
I just did it and it worked
image