Automating triggering of Jenkins jobs


As an application business analyst, create a process by using the Run Jenkins Job, Get Jenkins Job Build, and Get Queue Item elements in the Process designer of BMC Helix Innovation Studioto automatically trigger a Jenkins job.

Before you begin

Make sure that an administrator has configured the Jenkins connector. For more information, see Adding-a-Jenkins-connector-configuration.

Run Jenkins Job element properties

A Run Jenkins Job element triggers a Jenkins job.

The following table describes the Run Jenkins Job input properties:

Property

Description

Connection ID

The ID of the Jenkins connector.

Job

Location of the Jenkins job.

Specify the job location in one of the following ways:

  • Specify a path that includes the Jenkins project name.
    For example, SBE/01_Developer_Jobs/Test Sleep 
  • Specify the Jenkins job name.
    For example, Test Sleep
  • Specify the subpath of the Jenkins job.
    For example, job/SBE/job/01_Developer_Jobs/job/Test Sleep

Parameters

Parameters that you want to pass to the Jenkins job.

Delay in seconds

Time interval to delay the start of the Jenkins job.

The following table describes the Run Jenkins Job output properties:

Property

Description

Queue Item ID 

The ID of an item in the Jenkins queue.

It is an integer value. For example, 149634.

Get Jenkins Job Build element properties

A Get Jenkins Job Build element retrieves the build details of a Jenkins job.

The following table describes the Get Jenkins Job Build input properties:

Property

Description

Connection ID

The ID of the Jenkins connector.

Job

Location of the Jenkins job.

Specify the job location in one of the following ways:

  • Specify a path that includes the Jenkins project name.
    For example, SBE/01_Developer_Jobs/Test Sleep 
  • Specify the Jenkins job name.
    For example, Test Sleep
  • Specify the subpath of the Jenkins job.
    For example, job/SBE/job/01_Developer_Jobs/job/Test Sleep

Build ID

Build ID of the Jenkins job.

The Get Jenkins Job Build output property is a JSON that provides information such as job location, build ID, and result.

For example,

{
"result": "SUCCESS",
 "id":
"483",
 "url":
"http://<host name>:8080/job/SBE/job/01_Developer_Jobs/job/Test%20Sleep/483/",
"building": false,
"status": null
} 

Get Queue Item element properties

A Get Queue Item element retrieves the ID of an item in a Jenkins queue.

The following table describes the Get Queue Item input properties:

Property

Description

Connection ID

The ID of the Jenkins connector.

Queue Item ID

The ID of an item in the Jenkins queue.

You can map the output of the Run Jenkins Job element to this field.

The Get Queue Item output property is a JSON that provides information such as job location and build ID.

For example,

{
 "id":
"152645",
"executable": {   
"number": 483,   
"url": "http://clm-aus-000479.bmc.com:8080/job/SBE/job/01_Developer_Jobs/job/Test%20Sleep%20with%20Params/483/"
 },
"others": null,
"inQueueSince": 1617290746546
} 

To create a process to automatically trigger a Jenkins job

  1. Log in to BMC Helix Innovation Studio.
  2. Navigate to the Workspace tab, and select the application in which you want to create a process.
  3. In the application, select Processes, and click New.
    The system opens the Process designer.
  4. Drag the Run Jenkins Job element to the canvas and enter the values of the element properties.
  1. If required, add the Get Jenkins Job Build element and other elements, and enter the element properties.
  2. Specify the flow of execution and save the process.

Example: Setting up a process to automatically trigger a Jenkins job

Ajay is an application business analyst in Apex Global. He wants to automate the task of triggering a Jenkins job. To automate the task, he creates a process. Ajay uses the Create Document element to access attributes within the schema of the JenkinsParameters document definition. He adds the values for the document nodes and uses these values as input to run the Jenkins job. Ajay uses the Run Jenkins Job element to trigger the job.

Ajay performs the following actions to create the process to automate the triggering of a Jenkins job:

Step

Description

Example

1

Create the process.

22_1_Process to automate the triggering of a Jenkins job.png

2

Add the Create Document element properties.

22_1_Create document element details.png

a. To add a document, select the JenkinsParameters document definition.

22_1_Select a document definition.png

b. To add values for the document nodes, click Add/Remove Document Nodes, and select the key and value checkboxes of nodes.

22_1_Document nodes.png

For information about the Create Document element, see Creating-a-document-instance.

3

Add the Run Jenkins Job element properties.

22_1_Run Jenkins Job element details.png

4

In the Run Jenkins Job element properties, in the Parameters field, map the Create Template element output.

22_1_Run Jenkins Job-Parameters.png

5

Save the process.



 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*