• /
  • EnglishEspañolFrançais日本語한국어Português
  • Log inStart now

Jenkins job actions

|View as Markdown

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 username:apiToken for HTTP Basic Authentication. Generate the API token from your Jenkins user profile under Configure > API Token.

${{ :secrets:jenkinsAuthToken }}

url

String

Required. Jenkins server URL.

https://jenkins.example.com

jobName

String

Required. Name of the Jenkins job to trigger. For folder-based jobs, use forward slashes as separators.

deployments/production/my-job

parameters

Map

Optional. Build parameters as key-value pairs for parameterized builds. When provided, the action uses the /buildWithParameters endpoint automatically.

{"ENVIRONMENT": "production", "VERSION": "v1.2.3"}

selectors

List

Optional. JQ selectors to extract specific fields from the action output.

[{"name": "queueId", "expression": ".queueId"}]

The following table describes all output fields returned by this action.

Output

Type

Description

queueId

Int

Queue item ID, for example 123. Use with jenkins.queue.getItem to track build progress and retrieve the build number once execution starts.

queueUrl

String

Full queue URL, for example "http://jenkins.example.com/queue/item/123/".

statusCode

Int

HTTP status code. 201 indicates a successful trigger.

success

Boolean

true on success, false on failure.

errorMessage

String

Error message if the build failed to trigger. null on success.

The following example triggers a parameterized Jenkins build and captures the queue ID for tracking.

Workflow example

name: trigger-jenkins-build
description: 'Trigger a parameterized Jenkins build'
steps:
- name: trigger_build
type: action
action: jenkins.job.trigger
version: 1
inputs:
authToken: ${{ :secrets:jenkinsAuthToken }}
url: "https://jenkins.example.com"
jobName: "deployments/production-deploy"
parameters:
ENVIRONMENT: "production"
VERSION: "v1.2.3"
selectors:
- name: "queueId"
expression: ".queueId"
next: end

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 username:apiToken for HTTP Basic Authentication.

${{ :secrets:jenkinsAuthToken }}

url

String

Required. Jenkins server URL.

https://jenkins.example.com

jobName

String

Required. Name of the Jenkins job. For folder-based jobs, use forward slashes as separators.

deployments/production/my-job

buildNumber

Int

Optional. Specific build number to check. If not provided, returns the status of the last build.

42

selectors

List

Optional. JQ selectors to extract specific fields from the HTTP response.

[{"name": "buildStatus", "expression": ".responseBody | fromjson.result"}]

The following table describes all output fields returned by this action.

Output

Type

Description

response

Object

Build details from the Jenkins API. The result field values are SUCCESS, FAILURE, UNSTABLE, ABORTED, NOT_BUILT, or null if the build is still in progress.

{
"number": 42,
"result": "SUCCESS",
"building": false,
"duration": 45000,
"timestamp": 1625234567000,
"url": "http://jenkins.example.com/job/my-job/42/"
}

success

Boolean

true on success, false on failure.

errorMessage

String

Error message if the request failed. null on success.

The following example checks the status of a Jenkins build and branches on the result.

Workflow example

name: check-jenkins-build-status
description: 'Check the status of a Jenkins build and branch on result'
steps:
- name: check_build_status
type: action
action: jenkins.job.getStatus
version: 1
inputs:
authToken: ${{ :secrets:jenkinsAuthToken }}
url: "https://jenkins.example.com"
jobName: "deployments/production-deploy"
buildNumber: 42
selectors:
- name: buildStatus
expression: ".responseBody | fromjson.result"
- name: isBuilding
expression: ".responseBody | fromjson.building"
- name: handle_result
type: switch
switch:
- condition: ${{ .steps.check_build_status.outputs.buildStatus == "SUCCESS" }}
next: notify_success
next: notify_failure

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 username:apiToken for HTTP Basic Authentication.

${{ :secrets:jenkinsAuthToken }}

url

String

Required. Jenkins server URL.

https://jenkins.example.com

jobName

String

Required. Name of the Jenkins job to delete. For folder-based jobs, use forward slashes as separators.

temporary/test-job-123

selectors

List

Optional. JQ selectors to extract specific fields from the HTTP response.

[{"name": "statusCode", "expression": ".statusCode"}]

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: { "statusCode": 302, "body": "" }

success

Boolean

true on success, false on failure.

errorMessage

String

Error message if deletion failed. null on success.

The following example deletes a temporary Jenkins job.

Workflow example

name: cleanup-jenkins-job
description: 'Delete a temporary Jenkins job'
steps:
- name: delete_job
type: action
action: jenkins.job.delete
version: 1
inputs:
authToken: ${{ :secrets:jenkinsAuthToken }}
url: "https://jenkins.example.com"
jobName: "temporary/test-job-123"
next: end

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 username:apiToken for HTTP Basic Authentication.

${{ :secrets:jenkinsAuthToken }}

url

String

Required. Jenkins server URL.

https://jenkins.example.com

jobName

String

Required. Name of the Jenkins job. For folder-based jobs, use forward slashes as separators.

deployments/production/my-job

buildNumber

Int

Required. Build number to stop. Must be a currently running build.

42

selectors

List

Optional. JQ selectors to extract specific fields from the HTTP response.

[{"name": "statusCode", "expression": ".statusCode"}]

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: { "statusCode": 302, "body": "" }

success

Boolean

true on success, false on failure.

errorMessage

String

Error message if stopping the build failed. null on success.

The following example stops a running Jenkins build.

Workflow example

name: stop-jenkins-build
description: 'Stop a running Jenkins build'
steps:
- name: stop_build
type: action
action: jenkins.job.stop
version: 1
inputs:
authToken: ${{ :secrets:jenkinsAuthToken }}
url: "https://jenkins.example.com"
jobName: "deployments/production-deploy"
buildNumber: 42
next: end

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 username:apiToken for HTTP Basic Authentication.

${{ :secrets:jenkinsAuthToken }}

url

String

Required. Jenkins server URL.

https://jenkins.example.com

jobName

String

Required. Name of the Jenkins job. For folder-based jobs, use forward slashes as separators.

deployments/production/my-job

buildNumber

Int

Required. Build number to retrieve console output for.

142

selectors

List

Optional. JQ selectors to extract specific fields from the HTTP response. Console output text is in response.body.

[{"name": "buildLogs", "expression": ".responseBody"}]

The following table describes all output fields returned by this action.

Output

Type

Description

response

Object

Console output returned as plain text in response.body. Use selectors to extract specific information from the logs.

{
"body": "Started by user admin\nBuilding in workspace...\n[Pipeline] End of Pipeline\nFinished: SUCCESS",
"statusCode": 200
}

success

Boolean

true on success, false on failure.

errorMessage

String

Error message if retrieving console output failed. null on success.

The following example retrieves build logs and checks for errors.

Workflow example

name: get-jenkins-build-logs
description: 'Retrieve Jenkins build logs and check for errors'
steps:
- name: get_build_logs
type: action
action: jenkins.job.getConsoleOutput
version: 1
inputs:
authToken: ${{ :secrets:jenkinsAuthToken }}
url: "https://jenkins.example.com"
jobName: "deployments/production-deploy"
buildNumber: 142
selectors:
- name: buildLogs
expression: ".responseBody"
- name: hasErrors
expression: ".responseBody | contains(\"ERROR\") or contains(\"FAILED\")"
- name: check_for_errors
type: switch
switch:
- condition: ${{ .steps.get_build_logs.outputs.hasErrors }}
next: handle_error
next: end
Copyright © 2026 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.