Home > Enterprise >  How to set version number in Jenkins display build name
How to set version number in Jenkins display build name

Time:04-13

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?

CodePudding user response:

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
  • Related