This page provides a reference for Jenkins queue actions available in the workflow automation actions catalog. Use these actions to inspect and manage builds waiting in the Jenkins build queue.
Prerequisites
Before using Jenkins queue actions in workflow automation, you need:
- A Jenkins server reachable from New Relic Workflow Automation over HTTPS. If your Jenkins instance is behind a firewall or in a private network, allow inbound access from New Relic Workflow Automation.
- A Jenkins API token for the account the workflow runs as. Generate one from your Jenkins user profile: Configure > API Token > Add new Token.
- A secret in the New Relic Secrets Service containing the Base64-encoded value of
username:apiToken. Reference it in the workflow as${{ :secrets:<keyName> }}.
Get a Jenkins queue item
The action identifier is jenkins.queue.getItem.
Gets queue item details, including the build number once execution starts. Use this action to poll the queue after triggering a build with jenkins.job.trigger to retrieve the build number needed by other job actions.
The executable.number field in the response contains the build number once the build starts executing. It's null while the item is still in the queue.
The following table describes all available input fields for this action.
Input | Type | Description | Example |
|---|---|---|---|
authToken | String (secret) | Required. Base64-encoded |
|
url | String | Required. Jenkins server URL. |
|
queueId | Int | Required. Queue item ID returned from |
|
selectors | List | Optional. JQ selectors to extract specific fields from the HTTP response. |
|
The following table describes all output fields returned by this action.
Output | Type | Description |
|---|---|---|
response | Object | Queue item details. |
success | Boolean |
|
errorMessage | String | Error message if the request failed. |
The following example triggers a build and polls the queue until the build number is available.
Workflow example |
|---|
|
Cancel a queued Jenkins build
The action identifier is jenkins.queue.cancel.
Cancels a queued Jenkins build before it starts executing. Requires a queueId obtained from a prior jenkins.job.trigger call.
This action fails if the build has already started executing. To stop an already-running build, use jenkins.job.stop instead.
The following table describes all available input fields for this action.
Input | Type | Description | Example |
|---|---|---|---|
authToken | String (secret) | Required. Base64-encoded |
|
url | String | Required. Jenkins server URL. |
|
queueId | Int | Required. Queue item ID to cancel. The item must still be in the queue and not yet executing. |
|
selectors | List | Optional. JQ selectors to extract specific fields from the HTTP response. |
|
The following table describes all output fields returned by this action.
Output | Type | Description |
|---|---|---|
response | Object | Jenkins returns HTTP 204 (No Content) on successful cancellation. Jenkins returns 404 if the queue item is not found or has already started executing. Example: |
success | Boolean |
|
errorMessage | String | Error message if cancellation failed. |
The following example triggers a Jenkins build then cancels it before it starts executing.
Workflow example |
|---|
|
List all items in the Jenkins build queue
The action identifier is jenkins.queue.list.
Lists all items currently in the Jenkins build queue.
The following table describes all available input fields for this action.
Input | Type | Description | Example |
|---|---|---|---|
authToken | String (secret) | Required. Base64-encoded |
|
url | String | Required. Jenkins server URL. |
|
selectors | List | Optional. JQ selectors to extract specific fields from the HTTP response. |
|
The following table describes all output fields returned by this action.
Output | Type | Description |
|---|---|---|
response | Object | All queue items. Each item includes |
success | Boolean |
|
errorMessage | String | Error message if the request failed. |
The following example lists all items in the Jenkins build queue and extracts the count.
Workflow example |
|---|
|