Integration With Tekton⚓︎
ReportPortal integration with Tekton allows managing all automation results and reports in one place, visualizing metrics and analytics, team collaborating to associate statistics results.
For integration, take the following steps:
-
Log in to the ReportPortal console and navigate to the User Profile menu:
-
Copy the Access token and use it as a value while creating a kubernetes secret for the ReportPortal credentials:
-
In the Configuration examples section of the ReportPortal User Profile menu, copy the following
REQUIRED
fields:rp.endpoint
,rp.launch
andrp.project
. Insert these fields to thepytest.ini
file in root directory of your project: -
In root directory of the project create/update requirements.txt file and fill with following. it's mandatory to install report-portal python library (version may vary):
-
Create a custom Tekton task:
View: Custom Tekton task
apiVersion: tekton.dev/v1beta1 kind: Task metadata: labels: app.kubernetes.io/version: '0.1' name: pytest-reportportal namespace: edp spec: description: |- This task can be used to run pytest integrated with report portal. params: - default: . description: The path where package.json of the project is defined. name: PATH_CONTEXT type: string - name: EXTRA_COMMANDS type: string - default: python:3.8-alpine3.16 description: The python image you want to use. name: BASE_IMAGE type: string - default: rp-credentials description: name of the secret holding the rp token name: rp-secret type: string steps: - env: - name: HOME value: $(workspaces.source.path) - name: RP_UUID valueFrom: secretKeyRef: key: rp_uuid name: $(params.rp-secret) image: $(params.BASE_IMAGE) name: pytest resources: {} script: > #!/usr/bin/env sh set -e export PATH=$PATH:$HOME/.local/bin $(params.EXTRA_COMMANDS) # tests are being run from ./test directory in the project pytest ./tests --reportportal workingDir: $(workspaces.source.path)/$(params.PATH_CONTEXT) workspaces: - name: source
-
Add this task ref to your Tekton pipeline after tasks:
View: Tekton pipeline
- name: pytest params: - name: BASE_IMAGE value: $(params.image) - name: EXTRA_COMMANDS value: | set -ex pip3 install -r requirements.txt [ -f run_service.py ] && python run_service.py & runAfter: - compile taskRef: kind: Task name: pytest-reportportal workspaces: - name: source workspace: shared-workspace
-
Launch your Tekton pipeline and check that the custom task has been successfully executed:
-
Test reports will be displayed in the Launches section of the ReportPortal: