If you have a Jenkins instance you’re sharing with other developers, it can be quite hard to find your jobs. By default, Jenkins names your jobs as: #${BUILD_NUMBER}
and adds the date and time of execution. When you work with other team members, your history will look something like this:
Unless you know exactly which build was yours or the time you ran this job, it will take some clicking back and forth to find your job. Using two plugins, you can make your life much easier.
First, the Build Name and Description Setter plugin allows you to set the build name and description. Second, the build user vars plugin extends your options with user variables which we will use.
Changing a build name and description can be easily done in Jenkins GUI job configuration. In the Build Environment section, set Build name to: #${BUILD_NUMBER} ${BUILD_USER}
. If you’d like to make your history a bit more descriptive, you can add a description with your TARGET_SYSTEM
parameter: TARGETSYSTEM: ${TARGET_SYSTEM}
. Now, it will be much easier to find your job. Of course TARGET_SYSTEM is not a Jenkins built in variable but in this context it is used to define a specific environment on which jobs are running. If you are using any other variable for this specific purpose, you can use it here.
This will work for Freestyle projects. However, if you’re using pipelines like most people do, you can add this as a step in your Jenkinsfile:
stage('Add Build Description'){ steps { wrap([$class: 'BuildUser']) { buildName "#${BUILD_NUMBER} ${BUILD_USER}" buildDescription 'TARGETSYSTEM: ${TARGET_SYSTEM}' } } }
“Find your Jenkins pipeline faster” Tech Bite was brought to you by Kenan Ibrović, DevOps Engineer at Atlantbh.
Tech Bites are tips, tricks, snippets or explanations about various programming technologies and paradigms, which can help engineers with their everyday job.