CloudBees action: Publish test results

3 minute read

Use this action to publish test results if you are using a CloudBees platform workflow. This action supports many popular testing tools, and enables testing results from platform workflow run to be displayed in the Test results tab of Run details and in the Test insights analytics dashboard.

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

Inputs

Table 1. Input details
Input name Data type Required Description

test-type

String

Yes

The name of the testing tool[1].

results-path

String

Yes

The pattern, file, or directory path of the test report to convert.

[1] The testing tool name must be formatted correctly, in either all lowercase, or all uppercase.

Supported testing tools

Only the testing tools listed in the table below are supported for use in this action.

Use the given test-type input format to specify a testing tool.

Table 2. Supported testing tool names and test-type format

Supported tool name

Accepted test-type input formats

lowercase

UPPERCASE

GO

go

GO

Jest

jest

JEST

JMeter

jmeter

JMETER

JUnit

junit

JUNIT

MSTest

mstest

MSTEST

Playwright

playwright

PLAYWRIGHT

ProdPerfect

prodperfect

PRODPERFECT

Selenium

selenium

SELENIUM

TestNG

testng

TESTNG

Tosca

tosca

TOSCA

Usage examples

Basic example

The following is a basic example of using the action:

- name: Publish test results uses: cloudbees-io/publish-test-results@v2 with: test-type: TESTNG results-path: /example/mytest

Go test example

To use the GO testing tool, you must first capture the output into a log, and then convert the log into a JUnit test report. Then you can use this action to publish the test results to the CloudBees platform.

In the following example, the following external tools are used to capture the data and create a test report:

apiVersion: automation.cloudbees.io/v1alpha1 kind: workflow name: GO-test on: push: branches: - main jobs: GO-testing: steps: - name: Check out source code uses: cloudbees-io/checkout@v1 with: repository: gh-org/my-repo ref: main token: ${{ secrets.GIT_PAT }} - name: Get test reports uses: docker://golang:1.22-alpine shell: sh run: | export PATH="${PATH}:${GOPATH}/bin" go install github.com/jstemmer/go-junit-report@latest go install github.com/ctrf-io/go-ctrf-json-reporter/cmd/go-ctrf-json-reporter@latest mkdir ${{ cloudbees.workspace }}/test_reports go clean go test -v 2>&1 ./... | go-junit-report > ${{ cloudbees.workspace }}/test_reports/report.xml go test -json ./... | go-ctrf-json-reporter -output ${{ cloudbees.workspace }}/test_reports/report.json - name: Publish test results to platform uses: cloudbees-io/publish-test-results@v1 with: folder-name: ${{ cloudbees.workspace }}/test_reports test-type: go

After the run has completed, the test report is displayed in both Analytics  Test insights and Run details  Test results in the CloudBees platform.

GO test results
Figure 1. GO testing results displayed in Run details  Test results.

Playwright test example

In the following example, source code from a repository is checked out in the CloudBees platform and tested with the Playwright tool. After configuring AWS credentials, the test results are compressed and archived using Docker. The test results are uploaded to an AWS S3 bucket and published as evidence in the CloudBees platform.

Example workflow YAML file
apiVersion: automation.cloudbees.io/v1alpha1 name: trigger-publish-test-results-action kind: workflow on: pull_request: branches: - main push: branches: - main jobs: Playwright-Test: steps: - name: Check out source code uses: cloudbees-io/checkout@v1 with: repository: my-name/my-repo-name - name: PlayWright test uses: cloudbees-io/publish-test-results@v2 with: test-type: playwright folder-name: ${{ cloudbees.workspace }}/test_data/playwright/results_failed.json - name: Configure AWS credentials uses: cloudbees-io/configure-aws-credentials@v1 with: aws-region: us-east-1 aws-access-key-id: ${{ secrets.MY_AWS_ID }} aws-secret-access-key: ${{ secrets.MY_AWS_SECRET_KEY }} - id: compress-and-archive-test-evidence name: Compress and archive test evidence uses: docker://golang:1.20-alpine shell: sh run: | mkdir -p ${{ cloudbees.workspace }}/test-data/playwright/test-results tar -czf ${{ cloudbees.workspace }}/test-data/playwright/test-results.tar.gz -C ${{ cloudbees.workspace }}/test-data/playwright/test-results . - name: S3 upload test evidence archive uses: cloudbees-io/s3-upload-object@v1 with: file-path: ${{ cloudbees.workspace }}/test-data/playwright/test-results.tar.gz bucket-name: my-testing-logs s3-path: s3-folder/${{ cloudbees.run_id}}.tar.gz send-artifact-info: "true" Test-evidence: steps: - name: Publish evidence item uses: cloudbees-io/publish-evidence-item@v1 with: content: | - Run ID: ${{ cloudbees.run_id }} - [backend.tar](https://ourcompany.com/repo/backend.tar)