Using Testkube from CI/CD
Triggering Workflows from your CI/CD pipeline can be done in several ways:
- Using one of Testkubes native integrations (see below).
- Automating the Testkube CLI in your CI/CD tool.
- Directly calling the Testkube API.
CI/CD Integration Tutorials
The following tutorials are available for integrating Testkube with common CI/CD tools:
Native CI/CD Integrations
Native Integrations are available for
- Jenkins - https://plugins.jenkins.io/testkube-cli
- GitHub - https://github.com/marketplace/actions/testkube-action
- Azure Devops - https://marketplace.visualstudio.com/items?itemName=Testkube.testkubecli
The Workflow Details tab in the Testkube Dashboard shows preconfigured configurations for popular CI/CD tools to run the selected Workflow - Read More.
General Steps for CI/CD Integration
1. Utilize the Testkube CLI Docker Image
In your CI/CD pipeline configuration, specify the use of the kubeshop/testkube-cli
Docker image.
This image contains the necessary Testkube CLI for interacting with Testkube services - Read More.
2. Set Required Environment Variables
Define the following environment variables in your pipeline configuration:
TESTKUBE_API_KEY: Your Testkube API key (tkcapi_...).
TESTKUBE_ORG_ID: The organization ID for Testkube (tkcorg_...).
TESTKUBE_ENV_ID: The environment ID for Testkube (tkcenv_...).
These variables are crucial for authenticating and directing your tests to the correct Testkube environment.
3. Initialize Testkube Context
Within your pipeline script, execute a command to set the Testkube context using the environment variables. For instance:
testkube set context --api-key $TESTKUBE_API_KEY --org $TESTKUBE_ORG_ID --env $TESTKUBE_ENV_ID
This step configures the Testkube CLI with the correct parameters for your specific Testkube environment.
4. Trigger Testkube Tests
Finally, add a script step to trigger the desired Workflow in Testkube. For example:
testkube run testworkflow <workflow-name> -f
Replace <workflow-name>
with the specific name of the Test Workflow you wish to execute.
You can run any Testkube CLI command using the approach described above, check out the CLI Command Reference.