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
I believe the git command that does what you want is git tag --points-at=HEAD
this will list all tags pointing to the current commit or HEAD as it usually called in git. Since HEAD is also the default argument you can also do just git tag --points-at
.
The pipeline step for executing and returning the git tags one for each line, then becomes:
sh(returnStdout: true, script: "git tag --points-at")