> For the complete documentation index, see [llms.txt](https://docs.testery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.testery.io/integrations/ci-cd-integration-guide/jenkins.md).

# Jenkins

Testery integrates with Jenkins via the [Testery CLI](/integrations/testery-cli-docs.md) or [Testery REST API](/integrations/testery-rest-api.md). We strongly recommend using the CLI as it is usually faster to get running and provides better integration functionality. The CLI requires Python 3.6 or greater.

**Step 1. Retrieve your Testery API Token.** To retrieve your token, click **Settings → Integrations → Show API Token** and copy the token that is displayed. Keep this token secure as it allows access to Testery on your behalf. If you don't already have a Testery account, you can sign up for a free account in a few minutes [here](https://testery.io/signup).

**Step 2. Store your Testery API Token in Jenkins as a secret.** For more information on the various options for doing this, see <https://www.jenkins.io/doc/book/using/using-credentials/>

You can now access this token as follows in your `Jenkinsfile`:

```groovy
pipeline {
    // ...
    environment {
        TESTERY_API_TOKEN = credentials('testery-api-token')
    }
    // ...
}
```

**Step 3.** **Add steps to your Jenkins pipeline to install the** [**Testery CLI**](/integrations/testery-cli-docs.md) **and tell Testery when there are deployments ready to be tested.**

Here is a sample `Jenkinsfile`:

```groovy
pipeline {
    agent any

    stages {
        // ...
        stage('Testery Tests') {
            steps {
                script {
                    echo "Running E2E tests..."
                    def commit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
                    sh 'pip install testery --upgrade'
                    sh 'testery create-deploy --token ${TESTERY_API_TOKEN} --project <yourTesteryProjectKey> --environment <yourTesteryEnvironmentKy> --build-id ${BUILD_ID} --commit ${commit}' 
                }
            }
        }
        // ...
    }
}
```

**Step 4. Configure Testery to trigger a test run whenever there are** [**deployments**](/get-to-know-testery/deployments.md)**.**

Go to **Schedules**, click **Add New Schedule** and then specify that you want the tests to **Run on Deploy**. The Run on Deploy option will only be available after you have completed the previous steps.

![](/files/-MVXIye7qAFRjoBENSdZ)

**Step 5. You're all set!**

Tests will now run whenever your Jenkins pipeline is run. If you get stuck and would like any assistance, please don't hesitate to reach out to <support@testery.io>.
