Skip to content

cloudbees-io/cbci-run-job

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CloudBees action: Run a CloudBees CI job

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

Inputs

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

integration-name

String

No

The Plugin Integration name. Note: If this is provided url/username/token fields will be ignored.

url

String

No

The CloudBees CI server URL. Note: Only required if integration-name is empty.

username

String

No

The CloudBees CI username. Note: Only required if integration-name is empty.

token

String

No

The CloudBees CI token. Note: Only required if integration-name is empty.

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), TestNG (testng) and GO (go).

test-result-location

String

No

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

parameters

JSON string

No

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

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/TestNG/GO
        test-result-location: junit-service*
        parameters: '{"BRANCH_NAME":"main","ENV_NAME":"stage"}'

Usage example for plugin integration

In your YAML file, add:

jobs:
  my-cbci-plugin-job:
    steps:
    - name: Run a CloudBees CI job via plugin
      uses: cloudbees-io/cbci-run-job@v2
      with:
        integration-name: ${{ vars.CBCI_INTEGRATION_NAME }}
        job-name: "Integration_Job_Name"
        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 }}"

License

This code is made available under the MIT license.

References