CloudBees action: Run a CloudBees CI job

2 minute read

Use this action to trigger a CloudBees CI job. To learn more, refer to the CloudBees CI documentation.

All CloudBees action repositories are listed at CloudBees, Inc. on GitHub.

Inputs

Table 1. Input details
Input name Data type Required? Description

url

String

Yes

The CloudBees CI server URL.

username

String

Yes

The CloudBees CI username.

token

String

Yes

The CloudBees CI token.

job-name

String

Yes

The CloudBees CI job name.

test-type

String

No

Specifies the test type for generating a job test report. Supported test types are JUnit (junit) and TestNG (testng).

test-result-location

String

No

Specifies the test report file location. Accepts pattern matching, such as my-dir/*/my-file.[1]

parameters

JSON

No

Any additional CloudBees CI parameters, formatted as JSON data in key/value pairs.

[1] You must specify the test-result-location to publish your test results in the platform Test insights dashboard.

Outputs

Table 2. Output details
Output name Data type Required? Description

cbci_output

String

No

A JSON string containing the output key/values exposed by the invoked CloudBees CI pipeline.[1]

[1] You must parse each output parameter in the following format:

fromJSON(steps.<STEP-ID>.outputs.cbci_output).<OUTPUT_PARAMETER>

Replace <STEP_ID> with your step ID, and <OUTPUT_PARAMETER> with your parameter.

Usage examples

In your YAML file, add:

jobs: my-cbci-job: steps: - name: Run a CloudBees CI job uses: cloudbees-io/cbci-run-job@v2 with: url: ${{ vars.CBCI_URL }} username: ${{ secrets.CBCI_USERNAME }} token: ${{ secrets.CBCI_TOKEN }} job-name: "CloudBees_CI_job_name" test-type: JUnit test-result-location: junit-service* parameters: '{"BRANCH_NAME":"main","ENV_NAME":"stage"}'

Using output from CloudBees CI

In the following example, output is passed from CloudBees CI to the platform.

The jenkinsfile below is used to define the outputs:

node { stage('Build') { env.BUILD_NUMBER="1" env.TESTVAR="Test" } }

The platform workflow file below prints the BUILD_NUMBER and TESTVAR outputs from CloudBees CI:

jobs: CBCI-Output-Job: outputs: cbci_output: ${{ steps.my-output-job.outputs.cbci_output }} steps: - id: my-output-job name: Run CBCI Job uses: cloudbees-io/cbci-run-job@v2 with: url: ${{ vars.CBCI_URL }} username: ${{ secrets.CBCI_USERNAME }} token: ${{ secrets.CBCI_TOKEN }} job-name: cbci_job_with_output_name - id: expose-output-cbci name: Expose CBCI job output uses: docker://exozet/jq:1.6-r0 run: | echo "BUILD_NUMBER: ${{ fromJSON(steps.my-output-job.outputs.cbci_output).BUILD_NUMBER }}" echo "TESTVAR: ${{ fromJSON(steps.my-output-job.outputs.cbci_output).TESTVAR }}" Print-CBCI-Outputs: needs: [CBCI-Output-Job] steps: - id: print-cbci-output uses: docker://exozet/jq:1.6-r0 name: Print CBCI-Output-Job outputs run: | echo "BUILD_NUMBER: ${{ fromJSON(needs.CBCI-Output-Job.outputs.cbci_output).BUILD_NUMBER }}" echo "TESTVAR: ${{ fromJSON(needs.CBCI-Output-Job.outputs.cbci_output).TESTVAR }}"