Skip to content

Instantly share code, notes, and snippets.

@mroger
Last active May 13, 2019 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mroger/6b569beebfe2e9d77d29625cbceb7f46 to your computer and use it in GitHub Desktop.
Save mroger/6b569beebfe2e9d77d29625cbceb7f46 to your computer and use it in GitHub Desktop.
Jenkins file
pipeline {
agent any
options {
disableConcurrentBuilds()
}
stages {
stage('Checkout') {
steps {
deleteDir()
script {
env.gitBranch = checkout([
$class: 'GitSCM',
branches: scm.branches,
submoduleCfg: [],
userRemoteConfigs: [
[url: 'E:/Projects/Spring-boot/semantic-version/.git']
]
]).GIT_BRANCH
env.headTag = sh(returnStdout: true, script: 'git describe --all --exact-match `git rev-parse HEAD`').trim()
echo env.headTag
if (headTag =~ /^tags\/v\d+.\d+.\d+/) {
currentBuild.result = 'ABORTED'
error 'Ignoring build because there are no new changes'
}
}
}
}
stage('unit tests') {
steps {
sh "./gradlew clean test --console=plain"
}
}
stage('build') {
steps {
sh "./gradlew -Prelease -q printVersion"
sh "./gradlew clean build -Prelease --console=plain"
}
}
stage('release') {
steps {
sh "git fetch --tags"
sh "./gradlew -Prelease tag --console=plain"
}
}
}
post {
always {
sh "./gradlew --stop"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment