This page provides a reference for Jenkins job actions available in the workflow automation actions catalog. Use these actions to trigger and manage Jenkins builds.
Prerequisites
Before using Jenkins job 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> }}. - For folder-based jobs, the full folder path to the job using
/as the separator (for example,deployments/production/my-job).
Trigger a Jenkins job
The action identifier is jenkins.job.trigger.
Triggers a Jenkins build with optional parameters. On success, returns a queueId that you can use with jenkins.queue.getItem to track build progress and retrieve the build number once execution starts.
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. |
|
jobName | String | Required. Name of the Jenkins job to trigger. For folder-based jobs, use forward slashes as separators. |
|
parameters | Map | Optional. Build parameters as key-value pairs for parameterized builds. When provided, the action uses the |
|
selectors | List | Optional. JQ selectors to extract specific fields from the action output. |
|
The following table describes all output fields returned by this action.
Output | Type | Description |
|---|---|---|
queueId | Int | Queue item ID, for example |
queueUrl | String | Full queue URL, for example |
statusCode | Int | HTTP status code. |
success | Boolean |
|
errorMessage | String | Error message if the build failed to trigger. |
The following example triggers a parameterized Jenkins build and captures the queue ID for tracking.
Workflow example |
|---|
|
Get the status of a Jenkins build
The action identifier is jenkins.job.getStatus.
Gets the status of a Jenkins job build. Use this action to poll a build triggered by jenkins.job.trigger.
To check a specific build rather than the latest, provide its buildNumber. Obtain the build number by polling the queue with jenkins.queue.getItem after triggering the build.
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. |
|
jobName | String | Required. Name of the Jenkins job. For folder-based jobs, use forward slashes as separators. |
|
buildNumber | Int | Optional. Specific build number to check. If not provided, returns the status of the last build. |
|
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 | Build details from the Jenkins API. The |
success | Boolean |
|
errorMessage | String | Error message if the request failed. |
The following example checks the status of a Jenkins build and branches on the result.
Workflow example |
|---|
|
Delete a Jenkins job
The action identifier is jenkins.job.delete.
Permanently deletes a Jenkins job and all its build history. This operation cannot be undone.
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. |
|
jobName | String | Required. Name of the Jenkins job to delete. For folder-based jobs, use forward slashes as separators. |
|
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 302 (redirect) on successful deletion. The job is immediately removed. Example: |
success | Boolean |
|
errorMessage | String | Error message if deletion failed. |
The following example deletes a temporary Jenkins job.
Workflow example |
|---|
|
Stop a running Jenkins build
The action identifier is jenkins.job.stop.
Stops or aborts a running Jenkins build. Jenkins marks the build as ABORTED once stopped.
Requires the buildNumber of the running build. Obtain it by triggering the build with jenkins.job.trigger and then polling jenkins.queue.getItem.
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. |
|
jobName | String | Required. Name of the Jenkins job. For folder-based jobs, use forward slashes as separators. |
|
buildNumber | Int | Required. Build number to stop. Must be a currently running build. |
|
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 302 (redirect) on a successful stop request. Example: |
success | Boolean |
|
errorMessage | String | Error message if stopping the build failed. |
The following example stops a running Jenkins build.
Workflow example |
|---|
|
Get console output from a Jenkins build
The action identifier is jenkins.job.getConsoleOutput.
Retrieves console output and logs from a Jenkins build.
Requires the buildNumber. Obtain it by triggering the build with jenkins.job.trigger and then polling jenkins.queue.getItem.
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. |
|
jobName | String | Required. Name of the Jenkins job. For folder-based jobs, use forward slashes as separators. |
|
buildNumber | Int | Required. Build number to retrieve console output for. |
|
selectors | List | Optional. JQ selectors to extract specific fields from the HTTP response. Console output text is in |
|
The following table describes all output fields returned by this action.
Output | Type | Description |
|---|---|---|
response | Object | Console output returned as plain text in |
success | Boolean |
|
errorMessage | String | Error message if retrieving console output failed. |
The following example retrieves build logs and checks for errors.
Workflow example |
|---|
|