Hello!
I have repo https://gitlab.com/anton_patsev/maven-release-example3
My config .gitlab-ci.yaml
variables:
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
SSH_GIT_URL: "git@gitlab.com:anton_patsev/maven-release-example3.git"
stages:
- release
- build
release:
stage: release
image: maven:3.5.3-jdk-8
script:
- apt-get install -y openssh-client git
- mkdir -p ~/.ssh
- chmod 0700 ~/.ssh
- eval "$(ssh-agent -s)"
- ssh-add - <<< "${SSH}"
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- git config user.name $PUSH_USER_NAME
- git config user.email $PUSH_USER_EMAIL
- git remote set-url origin $SSH_GIT_URL
- git checkout master
- git reset --hard origin/master
- git status
- git branch
- git remote -v
- mvn $MAVEN_CLI_OPTS clean release:prepare -Dresume=false -DdryRun=false -Dmaven.test.skip=true -DscmCommentPrefix="Release pom [ci skip]"
only:
- master
create-branch-by-tag:
stage: release
image: maven:3.5.3-jdk-8
script:
- mkdir -p ~/.ssh
- chmod 0700 ~/.ssh
- eval "$(ssh-agent -s)"
- ssh-add - <<< "${SSH}"
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- git config user.name $PUSH_USER_NAME
- git config user.email $PUSH_USER_EMAIL
- git remote set-url origin $SSH_GIT_URL
- git checkout master
- git pull
- git reset --hard $(git describe --abbrev=0 --tags)
- echo "Get version package from pom.xml"
- version=`python -c "import xml.etree.ElementTree as ET; print(ET.parse(open('pom.xml')).getroot().find('{http://maven.apache.org/POM/4.0.0}version').text)"`
- echo $version
- echo "Create branch version"
- git checkout -b $version
- git config --global push.default simple
- echo "Push version branch"
- git push --set-upstream origin $version
only:
- master
release-build:
stage: build
script:
- mvn build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion} versions:commit
- mvn scm:checkin -Dmessage="[maven-scm] prepare release ${project.artifactId}-${project.version}" -DpushChanges=false
- mvn clean deploy -Purge
- mvn scm:tag -DpushChanges=false
- mvn build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit
- mvn scm:checkin -Dmessage="[maven-scm] prepare for next development iteration"
only:
- branch
except:
- tags
- master
when: manual
I cannot run pipeline on tag after ci skip (maven release)
How refactore .gitlab-ci.yaml for run command from tag or branch
My pipelines https://gitlab.com/anton_patsev/maven-release-example3/pipelines