Simplify tag management in tag-git-repos.groovy
There is no need to check tag existence. Tag can be "moved"
using -f/--force switch.
Change-Id: I48c6e33e00a48d0925ca87650efdf1672b7c8f4c
See: https://mirantis.jira.com/browse/PROD-19780
diff --git a/tag-git-repos.groovy b/tag-git-repos.groovy
index 373e029..ad74505 100644
--- a/tag-git-repos.groovy
+++ b/tag-git-repos.groovy
@@ -15,23 +15,7 @@
def gitRepoAddTag(repoURL, repoName, tag, credentials, ref = "HEAD"){
git.checkoutGitRepository(repoName, repoURL, "master", credentials)
dir(repoName) {
- def checkTag = sh(script: "git tag -l ${tag}", returnStdout: true)
- if(checkTag == ""){
- sh "git tag -a ${tag} ${ref} -m \"Release of mcp version ${tag}\""
- }else{
- def currentTagRef = sh(script: "git rev-list -n 1 ${tag}", returnStdout: true)
- if(currentTagRef.equals(ref)){
- common.infoMsg("Tag is already on the right ref")
- return
- }
- else{
- sshagent([credentials]) {
- sh "git push --delete origin ${tag}"
- }
- sh "git tag --delete ${tag}"
- sh "git tag -a ${tag} ${ref} -m \"Release of mcp version ${tag}\""
- }
- }
+ sh "git tag -f -a ${tag} ${ref} -m \"Release of mcp version ${tag}\""
sshagent([credentials]) {
sh "git push origin ${tag}"
}