Publish an Allure Report to the Artifacts tab
This tutorial provides an example pipeline that builds a Java Maven application and generates an Allure Report that you can view in the Harness UI.
Artifact tab publishing is supported in the Kubernetes infrastructure only.
Pipeline workflow
This pipeline has five steps that do the following:
Runs the Maven tests present in the project.
Generates the Allure Report using the
allure-results
generated as part of step 1. The Allure tool is present in thesolutis/allure:2.9.0
Docker image used as part of the step.Combines the Allure Report into a single HTML file.
Viewing an Allure Report in a browser requires running a web server via the
allure open
command. But this won't allow viewing the report after the CI pipeline is complete.Use the allure-combine tool to convert the Allure Report into a single HTML file. Running
allure-combine .
insideallure-report
generates thecomplete.html
file. This step uses theshubham149/allure-combine:latest
Docker image with theallure-combine
tool present in it.Publishes the report to a Google Cloud Storage (GCS) bucket.
Uses static web hosting in GCS to display the Allure Report on the Artifacts tab.
The
plugins/artifact-metadata-publisher
plugin adds the input URLs to the Artifacts tab in the Harness UI.
Pipeline requirements
To run this pipeline in your project, do the following.
Create a file secret with your GCP authorization credentials. Do the following:
a. Create a service account key as described in the Google Cloud documentation.
b. Create a Harness secret for your key.
Create the following connectors if you don't have them:
- GitHub Connector
- GCP Connector Use the file secret you just created for the GCP credentials.
- Docker Hub Connector
You can choose to download Harness images from the Harness Image Registry instead of Docker Hub.
Create a publicly available bucket in GCS to store the report.
Update the report URL with your GCS bucket name. See
YOUR_GCS_BUCKET_NAME
in steps 4 and 5 in the YAML pipeline below.
Pipeline template
pipeline:
name: "allure test report publisher "
identifier: allure_test_report_publisher
projectIdentifier: AllureReport
orgIdentifier: default
tags: {}
properties:
ci:
codebase:
connectorRef: YOUR_GITHUB_CONNECTOR
repoName: allure-examples/allure-testng-example
build: <+input>
stages:
- stage:
name: Allure test publisher
identifier: allure_test_publisher
type: CI
spec:
cloneCodebase: true
execution:
steps:
# STEP 1: run Maven tests
- step:
type: Run
name: Run tests
identifier: tests
spec:
connectorRef: YOUR_HARNESS_IMAGE_CONNECTOR
image: openjdk:11
shell: Sh
command: ./mvnw clean test site
# STEP 2: Generate allure report
- step:
type: Run
name: allure
identifier: allure
spec:
connectorRef: YOUR_HARNESS_IMAGE_CONNECTOR
image: solutis/allure:2.9.0
command: |
cd target
allure generate allure-results --clean -o allure-report
# STEP 3: Combine allure report
- step:
type: Run
name: combine report
identifier: allure_combine
spec:
connectorRef: YOUR_HARNESS_IMAGE_CONNECTOR
image: shubham149/allure-combine:latest
command: |
cd target/allure-report
allure-combine .
cd ../..
cp target/allure-report/complete.html .
# STEP 4: Upload to GCS
- step:
type: GCSUpload
name: upload-report
identifier: uploadreport
spec:
connectorRef: YOUR_GCP_CONNECTOR
bucket: demo-allure-report
sourcePath: target/YOUR_GCS_BUCKET_NAME/complete.html
target: <+pipeline.sequenceId>/index.html
# STEP 5: Publish upload report url in artifact tab
- step:
type: Plugin
name: publish metadata for allure report
identifier: publish_allure_report_metadata
spec:
connectorRef: YOUR_HARNESS_IMAGE_CONNECTOR
image: plugins/artifact-metadata-publisher
settings:
file_urls: https://storage.googleapis.com/YOUR_GCS_BUCKET_NAME/<+pipeline.sequenceId>/index.html
artifact_file: artifact.txt
serviceDependencies: []
infrastructure:
type: KubernetesDirect
spec:
connectorRef: YOUR_KUBERNETES_DELEGATE_CONNECTOR
namespace: harness-delegate-prod