Within my Jenkins pipeline script, I would like to do something like this:
sh("git tag ${BUILD_NUMBER}")
However, this wouldn't work if git isn't found on the shell.
Is there any Jenkins plugin that can do this from a Jenkins pipeline script?
Within my Jenkins pipeline script, I would like to do something like this:
sh("git tag ${BUILD_NUMBER}")
However, this wouldn't work if git isn't found on the shell.
Is there any Jenkins plugin that can do this from a Jenkins pipeline script?
There is no plugin support for this currently but might be in the future:
https://issues.jenkins-ci.org/browse/JENKINS-28335
While you go over this Jira issue take a look at Andrey Makeev's temporary solution. also documented here.
Here's how I do it, where shell and Version are custom functions and class, respectively, and shell is a drop-in replacement for the sh function:
void gitTag(Version releaseVersion) {
sshagent(['devops_deploy_DEV']) {
shell 'git tag -d \$(git tag)'
shell 'git fetch --tags'
echo "New release version ${releaseVersion.normalVersion}"
shell "git tag -fa ${releaseVersion.normalVersion} -m 'Release version ${releaseVersion.normalVersion}'"
}
}
You can find the source for this here.