Software Development

What is the proper syntax to define a custom Pipeline Name and Description within a Jenkinsfile?

KE Asked by Kevin Harrison · 14-09-2025
0 upvotes 12,422 views 0 comments
The question

I am moving my build logic from the Jenkins UI configuration into a Declarative Pipeline Jenkinsfile. I want to ensure that the job name and description are automatically updated in the dashboard whenever the script runs, rather than relying on manual entries in the web interface. Is there a specific block within the pipeline syntax to set these properties, and how can I include dynamic information like the build date in the description?

3 answers

0
SA
Answered on 16-09-2025

In a Declarative Pipeline, you can set these using the options block. For the description, use options { buildDiscarder(...); description('Your custom description here') }. However, if you want to change the display name of the build itself, you should use the currentBuild.displayName and currentBuild.description variables inside a script block within one of your stages. For example, script { currentBuild.description = "Built on ${new Date().format('yyyy-MM-dd')}" }. This is the most effective way to ensure that your Jenkins dashboard remains informative and that developers can quickly identify the status or purpose of a specific build without clicking through several menus.

0
ST
Answered on 19-09-2025

This works great for the individual build description, but if I want to change the "Job Name" that appears in the main folder view using code, is that even possible through the Jenkinsfile?

AN 20-09-2025

To change the actual Job Display Name (not just the build number), you can use the properties step at the very top of your Jenkinsfile. Use properties([pipelineTriggers([]), displayProperty('New Job Name')]). Be aware that the job name usually updates only after the first successful run of the new script. This is a common point of confusion for DevOps engineers who expect the UI to refresh immediately upon saving the file in Git.

0
DE
Answered on 05-10-2025

You should use currentBuild.displayName = "#${env.BUILD_ID} - My Custom Name" inside a script block. It makes the build history much easier to read at a glance.

KE 07-10-2025

I agree with Deborah. We recently implemented this across all our microservices, and it saved our QA team hours of time because they no longer had to cross-reference build IDs with Git commit hashes manually.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

Book Free Session