Issue
In the Jenkins UI, I want my builds to display as 1.0.1-snapshot.134 rather than simply #134. I know I can do this:
currentBuild.displayName = "app-name-#" + currentBuild.number
But that only gives the build number, not the version. Looking at the docs, I didn't see the version attribute. How do I supply that? I calculate the version in the environment
section like so:
// Build Version
MAJOR_MINOR_VERSION = "1.0.1-snapshot"
BUILD_VERSION = "${MAJOR_MINOR_VERSION}.${BUILD_NUMBER}"
Can I get this into the display name?
Solution
You can access variables in the environment
directive from within keys in the env
object in Groovy in the pipeline scope:
currentBuild.displayName = "app-name-#" + env.BUILD_VERSION
Answered By - Matt Schuchard
Answer Checked By - Timothy Miller (JavaFixing Admin)