Handle case of tag not already existing in release repo correctly

This commit is contained in:
Dan Hawkins 2018-12-01 10:43:26 +00:00
commit a0c6fc4621

View file

@ -137,7 +137,7 @@ def ArrayList<String> maketaglist(String buildstamp, String otherreleasetags) {
def boolean releasegittag(String postcommitshacode, String tag) {
def boolean tagadded = false
// Check if tag exists already
def int gitrevparsestatus = sh(script: "git rev-parse \"${tag}\" > \"${gitrevparseoutputfile}\"", returnStatus: true)
def int gitrevparsestatus = sh(script: "git rev-parse \"${tag}\" > \"${gitrevparseoutputfile}\" 2> /dev/null", returnStatus: true)
if (gitrevparsestatus == 0) { // Tag exists
def existingshacode = readFile(file: gitrevparseoutputfile).trim()
if (existingshacode != postcommitshacode) { // If the existing tag is not associated with HEAD
@ -173,12 +173,12 @@ def boolean releasegittags(String postcommitshacode, ArrayList<String> taglist)
def releasegitpush(String dryrunpush ) {
if (dryrunpush == "true") {
sh("git push -n --tags origin master")
summaryappend("Dry-Run-Push")
summaryappend(",Dry-Run-Push")
setunstable("The artifact(s) have not been pushed/saved (\"Dry run push\" parameter/option is selected)")
}
else {
sh("git push --tags origin master")
summaryappend("Push")
summaryappend(",Push")
}
}