pipeline { agent { docker { image 'openjdk:11-jdk' } } stages { stage('Build') { steps { sh './gradlew build' } post { success { archiveArtifacts artifacts: 'build/libs/*', fingerprint: true } } } stage('Publish') { when { expression { return sh(returnStdout: true, script: 'git tag --contains').trim().length() > 0 } } steps { sh './gradlew publish' } } } }