Set Test Suite Parameters Using Environment Variables in CD Pipelines
This use case demonstrates how KubeRocketCI uses environment variables to flexibly configure commands in deployment pipelines. Teams can dynamically adjust parameters by adding, modifying, or removing them without changing the test suite code. This provides precise control over quality gates, streamlines workflows, and allows pipelines to adapt to different environments or requirements while maintaining efficiency and quality standards.
Goalsβ
- Flexible and convenient preparation and validation of the testing environment using environment variables.
- The ability to manage environment variables by overriding, adding, or removing their values and keys to configure test parameters.
- A streamlined setup process that allows teams to focus on development without platform constraints.
Preconditionsβ
- KubeRocketCI instance with GitHub is configured.
- Developer has access to the KubeRocketCI instance using the Single-Sign-On approach.
- Developer has
Writepermissions for GitHub repository to merge the code.
Scenarioβ
To implement specific logic in deployment quality gate within the KubeRocketCI platform, follow these steps:
- Fork the Tekton Chart: Fork, clone and deploy the prepared Tekton chart that implements the required Tekton resources using environment variables.
- Add the Application: Add a simple application from the platform marketplace and build the application to prepare it for deployment.
- Add the Autotests: Set up the autotests with the clone strategy to include them in the Deployment.
- Create Deployment, Environment, and Set Variables: Create a Deployment, Set up an environment for the deployment, add Autotests as a quality gate to the deployment, and define the variable.
- Validate: Review the pipeline logs to ensure autotests execute correctly and produce the expected output.
Fork the Tekton Chartβ
The first step is to clone and install the Tekton chart:
-
In GitHub, create a private repository.
-
Clone your private repository to your local machine:

git clone git@github.com:<github_account_name>/variables-case-tekton.git
-
Copy the chart repository content to your newly created repository. The repository structure should be as follows:
Repository structure
variables-case-tekton.βββ Chart.lockβββ Chart.yamlβββ README.mdβββ chart_schema.yamlβββ ct.yamlβββ lintconf.yamlβββ templatesβ βββ pipelinesβ β βββ cdβ β βββ autotest-variables.yamlβ β βββ deploy-with-autotests-variables.yamlβ βββ tasksβ β βββ cdβ β βββ init-autotests-variables.yamlβ β βββ run-autotests-variables-java.yamlβ βββ triggersβ βββ cdβ βββ deploy-with-autotests-variables.yamlβββ values.yaml -
Update the component configuration in the
values.yamlfile:# Replace `example.domain.com` with the appropriate wildcard domain for your setup.dnsWildCard: "example.domain.com" -
Install the chart:
cd variables-case-tektonhelm upgrade --install custom-tekton-chart . -n krci
Add Applicationβ
As soon as the Helm chart is installed, the new deploy pipeline will appear in the Environment configuration window. The next step is to create an application from a template:
-
Create a new Project with the
Applicationtype using theCreatestrategy. Select the Projects section and click + Create project:
-
Select the Select ready template option, Simple Spring Boot Application and click Continue:

-
On the Git & project info tab, define the following values and click Continue:
- Git server:
github - Owner:
GitHub_username - Repository name:
spring-boot-app - Default branch:
main - Project name:
spring-boot-app - Description:
Simple spring boot application
- Git server:

-
On the Build config tab, define the values and click Continue:
- Codebase versioning type:
semver - Start version from:
0.1.0 - Suffix:
SNAPSHOT
- Codebase versioning type:

-
On the Review tab, verify the project configuration and click Create project:

-
On the congratulations menu, click Open project:

-
Select the Branches tab and click the Build button:

- Click the PipelineRun name to view its details:

- Wait until the build is successful and its status is Completed:

Add Autotestsβ
Now you need to create template autotests that will be executed when deploying the application:
-
To add an autotest, navigate to the Projects section on the navigation bar and click + Create project.
-
On the Create new project dialog, select Custom configuration -> Autotest -> Clone and click Continue:

- On the Git & project info tab, define the following values and click Continue:
- RepoUrl:
https://github.com/KubeRocketCI/demo-autotests-gradle - Git server:
github - Owner:
GitHub_username - Repository name:
autotests - Default branch:
master - Project name:
autotests - Description:
Simple autotests gradle

- On the Build config tab, define the values and click Continue:
- Autotest code language:
Java - Language version/framework:
Java17 - Build tool:
Gradle - Autotest report framework:
allure - Codebase versioning type:
semver - Start version from:
0.1.0 - Suffix:
SNAPSHOT

- On the Review tab, verify the project configuration and click Create project:

-
On the congratulations menu, click View all projects.
-
Click Close. Now the application and autotest are created:

Create Deployment, Environment, and Set Variablesβ
The next step is to configure a Deployment with appropriate deploy pipeline, application, autotests, and variables:
To utilize and manage various environments through the KubeRocketCI platform, the initial step is to onboard a new GitOps repository.
-
Navigate to the
Deploymentssection and click the Click here to add a repository button:
-
Click to the + Add GitOps repository:

-
Select the
Createstrategy andgithubserver, enter GitHub account name and click Save:
-
In the KubeRocketCI portal, navigate to Deployments tab and click the + Create deployment button:

-
On the Applications tab, add the
spring-boot-appapplication, specify the main branch for it, and click Continue:
-
On the Pipeline configuration tab, fill in the required fields and click Continue:
- Pipeline name:
demo-pipeline - Description:
Deployment with specific variables - Deployment type:
Container

- Pipeline name:
-
On the Review tab, verify the configuration and click Create deployment:

-
On the congratulations page, select Open deployment:

-
On the Deployment details page, click the + Create Environment button:

-
On the Basic configuration tab, define the following values and click Continue:
- Cluster:
in-cluster - Environment name:
qa - Description:
Testing environment

- Cluster:
-
On the Pipeline configuration tab, define the following values and click Continue:
- Trigger type:
Manual - Pipeline template:
deploy-with-autotests-variables - Clean pipeline template:
clean

- Trigger type:
-
On the Quality gates tab, click the pencil icon to edit the first quality gate. Specify the following parameters and click Update quality gate and then Continue:
- Quality gate type:
Autotest - Autotest:
autotests - Step name:
Autotest - Autotest branch:
master

- Quality gate type:
-
On the Review tab, verify the Environment configuration and click Create environment:

-
Click the Open environment button:

-
Select the Variables tab and click the Add variable button:

-
Enter
MY_COMMAND, and set the Value togradle -q hello. Then, click the Save button:
In the Tekton task run-autotests-gradle-variables, we have implemented logic to check for the MY_COMMAND variable. If it exists, the task uses the value of this variable as the command. If it is missing or empty, the task falls back to using the logic defined in the run.json file from the autotests repository.
run-autotests-gradle-variables.yaml
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: run-autotests-gradle-variables
labels:
app.kubernetes.io/based-on: "0.2"
{{- include "edp-tekton.labels" $ | nindent 4 }}
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/categories: Autotest Tools
tekton.dev/tags: autotest-tool
tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le"
spec:
description: >-
This task runs autotests for a specified Environment using either Maven or Gradle based on the provided configuration, extracting and executing the relevant commands from a `run.json` file.
workspaces:
- name: source
description: A workspace that contains the repository.
params:
- name: DEPLOYMENT_FLOW
type: string
- name: ENVIRONMENT
type: string
- name: base-image
type: string
steps:
- name: run-autotest
image: "$(params.base-image)"
workingDir: $(workspaces.source.path)
env:
- name: ENVIRONMENT
value: $(params.ENVIRONMENT)
- name: DEPLOYMENT_FLOW
value: $(params.DEPLOYMENT_FLOW)
envFrom:
- configMapRef:
name: $(params.DEPLOYMENT_FLOW)-$(params.ENVIRONMENT)
script: |
#!/bin/bash
set -exo pipefail
# Check if the MY_COMMAND variable is set and not empty
if [[ -n "${MY_COMMAND}" ]]; then
# If MY_COMMAND is defined, execute its content
eval "${MY_COMMAND}"
else
# If MY_COMMAND is not set, execute the existing logic
$(sed -n 's/.*"'$ENVIRONMENT'": "\(.*\)",/\1/p' run.json | awk -F '"' '{print $1}')
fi
-
Navigate to the Applications tab. Then click Configure deploy -> Latest -> Start deploy:

Validateβ
Now it is time to review the pipeline logs to ensure autotests pass successfully and application produces the expected output:
-
To find autotests logs, navigate to CI/CD Pipelines -> PipelineRuns and wait until all pipelines are done:

-
Click on the autotests-variables-gradle-run-xxxxx PipelineRun, select the run autotests stage and the run autotests task in the logs page. You will see your autotests output:
