Skip to content

CI/CD Integration

Since Jikken tests already live in your code repository, and running them is as simple as executing a CLI command, it’s easy to integrate them into your existing CI/CD pipeline.

Here, we’ll show what your configuration might look like in order to run tests after each deployment, with examples for GitHub Actions, CircleCI, and Jenkins.

Installation script

We provide a simple installation script that can be used to install the latest version of Jikken via curl, with no other required tooling. This script was designed for the CI/CD use case, and will be used as the installation method in our examples. Please note that the script only supports Linux systems.

It is available at https://jikken.io/install.sh.

Check out our installation docs for other ways to install Jikken on Linux, Mac, or Windows.

Variables & secrets

You may need environment variables and/or secrets for your test execution. For example, if you’re using the Jikken cloud platform, an API key is required in order to stream telemetry data.

In the examples below, we using environment variables to specify the Jikken environment and the base URL for the APIs we’re testing, and secrets to specify our API key and a test user password.


See the documentation for your CI/CD provider to review how to configure variables and secrets.

GitHub Actions: variables, secrets
CircleCI: variables
Jenkins: credentials

Example files

GitHub Actions

workflow.yaml
jobs:
build:
...
deploy:
...
test:
needs: deploy
runs-on: ubuntu-latest
environment: dev
steps:
- uses: actions/checkout@v4
- name: Install Jikken
run: |
curl https://jikken.io/install.sh | bash
- name: Run Jikken tests
run: ./jk run --junit jikken-test-results.xml tests/
env:
JIKKEN_API_KEY: ${{ secrets.JIKKEN_API_KEY }}
JIKKEN_ENVIRONMENT: ${{ vars.JIKKEN_ENVIRONMENT }}
JIKKEN_GLOBAL_API_BASE: ${{ vars.JIKKEN_API_BASE }}
JIKKEN_GLOBAL_TEST_USERNAME: ${{ vars.JIKKEN_TEST_USERNAME }}
JIKKEN_SECRET_TEST_PASSWORD: ${{ secrets.JIKKEN_TEST_PASSWORD }}
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: jikken-test-results
path: jikken-test-results.xml
if: always()

This workflow file has a test job, which executes after deploy has completed, and specifies an environment for variable resolution.

The job has steps to install Jikken (via the provided script) and execute all tests in a specific directory. We inject the variables for the Jikken environment and API key, as well as custom global variables for the base API URL and some user credentials to be used in a test. We also use the --junit option when running Jikken to output a JUnit XML test result file, which is then uploaded as a jikken-test-results artifact in the last step. Note that the upload step is configured to always run, to ensure our results are still uploaded in the case of test failures.

See the official documentation for more details on GitHub Actions and workflow files.

CircleCI

config.yaml
version: 2.1
jobs:
build:
...
deploy:
...
test:
docker:
- image: ubuntu:latest
steps:
- checkout
- run:
name: Install Jikken
command: curl https://jikken.io/install.sh | bash
- run:
name: Run Jikken Tests
command: ./jk run --junit jikken-test-results.xml tests/
environment:
JIKKEN_API_KEY: $JIKKEN_API_KEY
JIKKEN_ENVIRONMENT: $JIKKEN_ENVIRONMENT
JIKKEN_GLOBAL_API_BASE: $JIKKEN_API_BASE
JIKKEN_GLOBAL_TEST_USERNAME: $JIKKEN_TEST_USERNAME
JIKKEN_SECRET_TEST_PASSWORD: $JIKKEN_TEST_PASSWORD
- store_test_results:
path: jikken-test-results.xml
workflows:
my-workflow:
jobs:
- build
- deploy:
requires: build
- test:
requires: deploy
context: dev

This configuration file has a test job with steps to install Jikken (via the provided script) and execute all tests in a specific directory. We inject the variables for the Jikken environment and API key, as well as custom global variables for the base API URL and some user credentials to be used in a test. We also use the --junit option when running Jikken to output a JUnit XML test result file, which is then stored in the last step. The store test results step will always run, so that we still see the results if any tests fail.

We then configure the workflow so that our test job is dependent on the deploy job to run, and ensure that it uses the correct context for our variables.

See the official documentation for more details on CircleCI and configuration files.

Jenkins

Jenkinsfile
pipeline {
agent {
docker {
image 'ubuntu:latest'
}
}
stages {
stage('Build') {
...
}
stage('Deploy') {
...
}
stage('Test') {
environment {
JIKKEN_API_KEY = credentials('jikken-api-key')
JIKKEN_ENVIRONMENT = ${JIKKEN_ENVIRONMENT}
JIKKEN_GLOBAL_API_BASE = ${JIKKEN_API_BASE}
JIKKEN_GLOBAL_TEST_USERNAME = ${JIKKEN_TEST_USERNAME}
JIKKEN_SECRET_TEST_PASSWORD = credentials('jikken-test-user-password')
}
steps {
echo 'Installing Jikken'
sh 'curl https://jikken.io/install.sh | bash'
echo 'Executing Jikken tests'
sh './jk run --junit jikken-test-results.xml tests/'
}
}
}
post {
always {
echo 'Reporting test data'
junit 'jikken-test-results.xml'
}
}
}

This Jenkinsfile has a 'Test' stage, which executes after 'Deploy' has completed.

The stage has steps to install Jikken (via the provided script) and execute all tests in a specific directory. We inject the variables for the Jikken environment and API key, as well as custom global variables for the base API URL and some user credentials to be used in a test. We also use the --junit option when running Jikken to output a JUnit XML test result file.

We then configure a post step where we use the junit plugin to report our test results. Note that we specify a condition of always, to ensure our results are still uploaded in the case of test failures.

See the official documentation for more details on Jenkins and Jenkinsfiles, and find information on the JUnit plugin here.