GitlabCI :: Tag is not build if the last commit message is annotated with [skip ci]

Summary

Hello,

if i create a tag based on a commit annotated with [skip ci] the tag will not trigger a pipeline build.

Steps to reproduce

  • Create a git repository in GitLab (using latest Gitlab CE Version)
  • Create a basic .gitlab-ci.yml file to ensure a pipeline will be created if commited correctly
touch someFile1.txt
touch someFile2.txt
git add -A 
git commit -m "some new text files"
git push # will trigger a new pipeline (as expected)

touch someFile3.txt
git add -A
git commit -m "[skip ci] should not be built"
git push # wont trigger a new pipeline (as expected)

git tag -a v1.0 -m "my awesome tag" # see the message does not contain [skip ci]
git push --tags # wont trigger a new pipeline because gitlab recognize the [skip ci] of the last commit instead of the tag message.

What is the current bug behavior?

  • The tag-pipeline wont be created if last commit message is annotated with [skip ci]

What is the expected correct behavior?

  • The tag-pipeline should be skipped if the tag message contains [skip ci] instead of the last commit message

Results of GitLab environment info

not needed

Results of GitLab application Check

not needed

Project

https://gitlab.com/SeaLife/issue-41535/pipelines

Background information

I've tried to create a "release step" with maven... I show you my current gitlab-ci.yml, it should clearify my use-case:

## Gitlab CI File (Builds a java application and create a docker image based on a Dockerfile)

variables:
  DOCKER_IMAGE_NAME: swagger-admin-ui
  DOCKER_NAMESPACE: sealife
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode -P r3ktm8"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"

stages:
- release       # release stage (just for builds on master)
- java          # build the java application
- java-push     # push the jar to the artifactory
- docker        # build the docker image
- docker-push   # used to push against the docker hub

cache:
  paths:
    - .m2/repository/
    - "**/target/"

##################################################################
##  Maven Build (building the application)
##################################################################

compile-devels:
  stage: java
  except:
  - master
  - tags
  image: "maven:3.5-jdk-8-alpine"
  script:
  - "curl --silent https://git.r3ktm8.de/snippets/2/raw | sh"
  - "mvn $MAVEN_CLI_OPTS clean compile test package"
  artifacts:
      paths:
      - "**/target/*.jar"
      - "**/target/*.war"
      expire_in: 1mo

compile-master:
  stage: java
  only:
  - tags
  image: "maven:3.5-jdk-8-alpine"
  script:
  - "curl --silent https://git.r3ktm8.de/snippets/2/raw | sh"
  - "sh release.sh"
  - "mvn $MAVEN_CLI_OPTS clean compile test package"
  artifacts:
      paths:
      - "**/target/*.jar"
      - "**/target/*.war"
      expire_in: 1000yr

#### RELEASE STEP (relevant for the bug i think)

create-tag:
  stage: release
  only:
  - master
  image: "ubuntu:18.04"
  script:
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
  - eval $(ssh-agent -s)
  - echo "$CI_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
  - apt-get update
  - apt-get upgrade -y
  - apt-get install -y ssh git maven curl
  - mkdir -p ~/.ssh
  - chmod 700 ~/.ssh
  - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
  - git clone $CI_SSH_URL tmp_project
  - cd tmp_project
  - "curl --silent https://git.r3ktm8.de/snippets/2/raw | sh"
  - git config --global user.name "Gitlab CI"
  - git config --global user.email "r3ktm8gitlab@gmail.com"
  - git fetch
  - git checkout master
  - git pull
  - sh release.sh
  - export MVN_VERSION=$(./curr-version.sh)
  - git commit -am "[skip ci] Create a new maven release by Gitlab CI Runner"
  - git push -u origin master
  - git tag -a $MVN_VERSION -m "Created a new Release by the Gitlab CI Runner"
  - git push -u origin --tags
  - sh prepare-next-dev.sh
  - git commit -am "[skip ci] created new development version"
  - git push -u origin master
  - cd ..
  - rm -rf tmp_project


##################################################################
##  Push the Application to Artifactory
##################################################################
deploy-java:
  stage: java-push
  except:
  - master
  image: "maven:3.5-jdk-8-alpine"
  script:
  - "curl --silent https://git.r3ktm8.de/snippets/2/raw | sh"
  - "mvn $MAVEN_CLI_OPTS deploy"

##################################################################
##  Docker Container (Build)
##################################################################

build-image:
  stage: docker
  image: docker:latest
  except:
  - master
  services:
  - docker:dind
  script:
  - "docker pull ubuntu"
  - "docker build -t $DOCKER_NAMESPACE/$DOCKER_IMAGE_NAME:$CI_COMMIT_REF_NAME -t $DOCKER_NAMESPACE/$DOCKER_IMAGE_NAME:latest ."

##################################################################
##  Docker Container (Publish)
##################################################################

publish-docker-latest:
  stage: docker-push
  image: docker:latest
  allow_failure: true
  except:
  - master
  services:
  - docker:dind
  script:
  - "docker login -u=$DOCKER_HUB_USER -p=$DOCKER_HUB_PASSWORD"
  - "docker push $DOCKER_NAMESPACE/$DOCKER_IMAGE_NAME:latest"

publish-docker-tag:
  stage: docker-push
  image: docker:latest
  allow_failure: true
  services:
  - docker:dind
  only:
  - tags
  script:
  - "docker login -u=$DOCKER_HUB_USER -p=$DOCKER_HUB_PASSWORD"
  - "docker push $DOCKER_NAMESPACE/$DOCKER_IMAGE_NAME:$CI_COMMIT_REF_NAME"

Its not a bug, its a feature

If this is not a bug, it should be a big improvement i think...

Edited by 🤖 GitLab Bot 🤖