Second tag pipeline is always created - ci-skip does not work

Hi community,

I’m using GitLab.com. I need to create a tag in my pipeline and a release using the release-cli.

But as soon as a git tag is created in the pipeline, a second pipeline is automatically started:

This is my simplified ci-script:

stages: [ build ]

variables:
  APP_VERSION: "1.0.${CI_PIPELINE_IID}"

build application:
  image: python:alpine3.17
  stage: build
  rules:
    - if: $CI_PIPELINE_SOURCE == "web"
    - if: $CI_PIPELINE_SOURCE == "trigger"
  before_script:
    - "apk add curl git"
    - git config --global user.email "<my mail>" && git config --global user.name "GitLab-CI"
    - curl --location --output /usr/local/bin/release-cli "https://gitlab.com/api/v4/projects/gitlab-org%2Frelease-cli/packages/generic/release-cli/latest/release-cli-linux-amd64"
    - chmod +x /usr/local/bin/release-cli
  script:
    - echo "build application"
  after_script:
    - git tag -a "Release-${APP_VERSION}" -m "[skip ci]"
    - git push "https://gitlab-ci:$PROJECT_ACCESS_TOKEN_SECRET@$CI_SERVER_HOST/$CI_PROJECT_PATH.git" HEAD:$CI_COMMIT_REF_NAME --tags -o ci.skip
    - 'release-cli create --name "Release-$APP_VERSION" --description "Deployment: $CI_PROJECT_NAME $APP_VERSION" --tag-name "Release-$APP_VERSION"'

None of the following options prevent the second pipeline:

  • git option parameter -o ci.skip
  • git commit message “[skip ci]”
  • general pipeline rules

Thanks for taking the time in my request.

Ok, the problem is solved with a few adjustments, perhaps as a workaround:

  1. Customize the workflow rules
  2. Customize the git commands

Part 1. Customize the workflow rules:

workflow:
  name: "Pipeline for commit '$CI_COMMIT_TITLE'"
  rules:
    - if: $CI_COMMIT_TAG_MESSAGE =~ /skip ci/
      when: never
    - if: $CI_PIPELINE_SOURCE == "push"
      when: never
    - if: $CI_PIPELINE_SOURCE == "web"

Part 2. Customize the git commands:

- git tag -a "Release-${APP_VERSION}" -m "Release-${APP_VERSION} [skip ci]"
- git push "https://gitlab-ci:$PROJECT_ACCESS_TOKEN_SECRET@$CI_SERVER_HOST/$CI_PROJECT_PATH.git" HEAD:$CI_COMMIT_REF_NAME --tags

The important step at this point is that the push option -o ci.skip must not be used. The ci.skip option always triggers another pipeline.