How do I graphically render / add a branch in Jenkins?
I am building a pipeline for Jenkins build and I was wondering if it is possible in some way to tag / render a build branch in Jenkins in the same way as it is possible in TeamCity.
I am using a declarative pipeline defined in a separate git repository and Jenkins 2.46.3.
It is not obvious from the figure that the last 2 builds were performed on a separate branch:
thank
source to share
You can change the display name and description of the current assembly using the following code:
currentBuild.displayName = env.BRANCH_NAME
currentBuild.description = 'Final Release'
This was highlighted recently in the BlueOcean 1.1 announcement , which shows that both of them, as opposed to the normal interface, only show displayName
.
An example modified displayName
from our public instance looks like this:
You can find the code that generates this in our shared library here and here , mainly this:
currentBuild.displayName = "#${currentBuild.getNumber()} - ${newVersion} (${increment})"
As you mark Declarative Pipelines add that you have to wrap this code in a block of script
course. So likely (untested):
pipeline {
agent any
stages {
stage('Example') {
steps {
echo 'Hello World'
script {
currentBuild.displayName = env.BRANCH_NAME
}
}
}
}
}
Alternatively, you can extract it into a separate function.
source to share