@@ -125,6 +125,10 @@ node {
125125 // deploy stage only if branch is main or dev
126126 if (env. BRANCH_NAME == " main" || env. BRANCH_NAME == " dev" ) {
127127 stage(' deploy' ) {
128+ // determine project version
129+ String projectVersion = sh(returnStdout : true , script : " set +x && cd ${ projectName} ; ./gradlew -q " +
130+ " ${ (env.BRANCH_NAME == "dev") ? "devVersion" : "currentVersion"} " ). toString(). trim()
131+
128132 // get the sonatype credentials stored in the jenkins secure keychain
129133 withCredentials([usernamePassword(credentialsId : mavenCentralCredentialsId, usernameVariable : ' mavencentral_username' , passwordVariable : ' mavencentral_password' ),
130134 file(credentialsId : mavenCentralSignKeyFileId, variable : ' mavenCentralKeyFile' ),
@@ -135,7 +139,8 @@ node {
135139 " -Ppassword=${ env.mavencentral_password} " +
136140 " -Psigning.keyId=${ env.signingKeyId} " +
137141 " -Psigning.password=${ env.signingPassword} " +
138- " -Psigning.secretKeyRingFile=${ env.mavenCentralKeyFile} ${ (env.BRANCH_NAME == "dev") ? " -Psnapshot" : ""} "
142+ " -Psigning.secretKeyRingFile=${ env.mavenCentralKeyFile} " +
143+ " -PdeployVersion='$projectVersion '"
139144
140145 // see https://docs.gradle.org/6.0.1/release-notes.html "Publication of SHA256 and SHA512 checksums"
141146 def preventSHACheckSums = " -Dorg.gradle.internal.publish.checksums.insecure=true"
@@ -150,9 +155,6 @@ node {
150155 }
151156
152157 // notify rocket chat
153- String projectVersion =
154- sh(returnStdout : true , script : " set +x && cd ${ projectName} ; ./gradlew -q printVersion" )
155- projectVersion = " ${ projectVersion.trim()}${ (env.BRANCH_NAME == "dev") ? "-SNAPSHOT" : ""} "
156158 String successMsg = " deployment of version $projectVersion from branch '$currentBranchName ' to sonatype " +
157159 " successful. If this is a deployment from 'main' pls remember visiting https://oss.sonatype.org to " +
158160 " stag and release artifact!\n " +
0 commit comments