This is the same as an answered question from over a year ago: Jenkinsfile get current tag
The accepted answer there is not working for me and I'm thinking the behavior must have changed within the pipeline since then.
My repo has tags (pushed to origin!), and I've added the Jenkins option to discover tags, however I cannot harvest or reference them from the pipeline steps. It just shows up null.
In my MultiBranch Pipeline job I have added the "Discover tags" step.
I have a git repo with a release tag set:
myhost$ git fetch
myhost$ git tag
0.0.42
myhost$ git tag --sort version:refname
0.0.42
In the Jenkinsfile I've tried:
sh "git tag --sort version:refname | tail -1 > version.tmp"
sh "cat version.tmp"
and:
sh(returnStdout: true, script: "git tag --sort version:refname | tail -1").trim()
Both of them return with nothing (null)