Using the Job Name Template

Article ID:360032829132
2 minute readKnowledge base

Description

In an CloudBees CD (CloudBees Flow) enterprise installation, the default job name can cause confusion when you try to find a specific job. The default job name consists of the word "job" followed by the job id and a date-time stamp, which is not very descriptive. By customizing the job name template on individual procedures, you can more easily find the jobs. The job name template can use the system properties, allowing you to customize the job names to make them context sensitive.

Solution

When you create or edit a procedure, you use the Job Name Template field to create the job name when the procedure runs. This can be a powerful tool because the template can use properties and parameters in the name and any of the intrinsic or user-defined properties or parameters (as long as they exist before the job runs).

The following figure illustrates that, out of the box, no Job Name Template is defined, and the default job name is rather uninformative.

By customizing the Job Name Template with various properties and parameters, the job name will have more meaning to users. Several sample jobs with more descriptive job names are illustrated in the following figure.

In the above examples, the following job name templates were defined:

$[ec:projectName]`$[ec:procedureName]$[ec:launchedByUser]_$[/increment /server/jobCounter]`

  • job 16 in above list

$[ec:projectName]`$[ec:procedureName]_branch$$[ec:launchedByUser]-$[/increment /server/jobCounter]`

  • job 17, where projectName is Product_Release_1.0, and brancName is Release_1.0

$[ec:launchedByUser]`$[ec:buildName]$[ec:buildType]_$[/increment /server/jobCounter]`

  • job 13 and 12, with different parameter values defined

As you can see, customizing names in the Job list makes it much easier to find specific jobs.

You can also use qualifiers to the properties, such as $[/myProject/releaseVersion], or $[/myWorkflow/buildType]. Remember that the procedure must run in a workflow context when using the myWorkflow properties or this value will be undefined and the job will not start.

Some customers use the unique jobId included in the job name template. Be advised that if you export from one CloudBees CD (CloudBees Flow) system to another, the jobId may no longer be unique because each CloudBees CD (CloudBees Flow) system will have a different set of job numbers and numbers may be duplicated.

As of CloudBees CD (CloudBees Flow) version 5.0, jobID will be in the form of an UUID which will also render it very difficult to use in a jobName

To alleviate this problem, it may be useful to create your own system wide unique ID number as follows:

$[/myProject/projectName]`$[/myProcedure/procedureName]$[/increment /server/jobCounter]`

Permanent change of default Job template:

If you’d like to change the default simple job name style to your own, so you don’t need to fill out the Job name Template field every time you create new Procedure?

Please go to "Administration" tab, select "Server" menu right below of the tab, and click "Settings" link at right top.
You can see "Job Name Template" field and it’s value "job$[/myJob/jobId]$[/timestamp]"

Change this value to your own pattern which should make new job can contain unique ID everytime new job is created.

For example:

From:
job$[/myJob/jobId]$[/timestamp]

to:
$[/myProject/projectName]-$[/myProcedure/procedureName]-$[/myJob/jobId]_$[/timestamp]


will assign your new job name based on your project name-procedure name-job name_unique ID based on time stamp.
Please, do not forget to press OK button at buttom of this page, so your changes can be saved.