diff --git a/release/do.groovy b/release/do.groovy index a86bf04..2438b54 100644 --- a/release/do.groovy +++ b/release/do.groovy @@ -129,14 +129,26 @@ def ArrayList maketaglist(String buildstamp, String otherreleasetags) { } def boolean releasegittag(String postcommitshacode, String tag) { + def boolean tagadded = false // Check if tag exists already - def retvalue = sh(script: "git rev-parse ${tag} >2 /dev/null", returnStdout: true, returnStatus: true) - echo "retvalue: ${retvalue} class: ${retvalue.getClass()}" - - - // Tag - sh("git tag ${tag}") - summaryappend("(${tag}),") + def existingshacode = sh(script: "git rev-parse ${tag}", returnStdout: true).trim() + if (existingshacode?.trim()) { // If tag/sha code does exist + if (existingshacode != postcommitshacode) { // If the existing tag is not associated with HEAD + // This is a problem - The tag is already at another position in git repo + setunstable("The tag ${tag} has been used at another commit other than HEAD - You must decide what to do with it - Not good practice to delete it or move it") + summaryappend("(${tag} - Could not add!),") + } + else { + summaryappend("(${tag} - Already added),") + } + } + else { // If sha code does not exist already + // Tag + sh("git tag ${tag}") + summaryappend("(${tag}),") + tagadded = true + } + return tagadded } def boolean releasegittags(String postcommitshacode, ArrayList taglist) {