Is there a way to get the current tag ( or null if there is none ) for a job in a Jenkinsfile? The background is that I only want to build some artifacts ( android APKs ) when t
best way from my site is:
git tag --sort=-creatordate | head -n 1
with:
latestTag = sh(returnStdout: true, script: "git tag --sort=-creatordate | head -n 1").trim()
Than you can handle with simple regex, for prefix/suffix/version_number what is to do with the tag.
other solution:
git describe --tags --abbrev=0
of course this is the current/latest tag in git. Independent from writing.
sh(returnStdout: true, script: "git describe --tags --abbrev=0").trim()