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
All the other answers yield an output in any case even if HEAD is not tagged. The question was however to return the current tag and "null" if there is nothing like that.
git tag --contains
yields the tag name name if and only if HEAD is tagged.
For Jenkins Pipelines it should look like this:
sh(returnStdout: true, script: "git tag --contains").trim()