Integrating Crusher tests with Jenkins
Integration with Jenkins can be done easily with the help of crusher-cli
. This guide will cover how you can trigger tests from your Jenkins pipeline
Example repo
For reference, you can take a look at the example repo which uses jenkins to trigger crusher tests.
JenkinsFile
pipeline {
agent {
docker {
image 'circleci/node:12.14.0-browsers'
}
}
stages {
stage('Test') {
steps {
// run crusher tests
sh 'npx crusher-cli test:run --token=<random_token_here> --project-id=<your_project_id>'
}
}
}
}
The above JenkinsFile
is doing the following things,
- Using
node:12.14.0
docker image as a base to prepare a basic node environment. (Needed forcrusher-cli
) - Triggering tests through
crusher-cli
test:run command in your project from—token
and --project-id
passed. (Look at how to get the token and project id)
Getting token and project id
To get your user token and project id,
- Open Crusher and go to
Settings>Integrations
- Copy the command from the
CI/CD
command box. - Replace the command with the newly copied command.