Jenkins
The fore ai Jenkins integration runs tests using the CJ Action docker image. Any Jenkins agent with Docker available can run fore ai tests.
Prerequisites
1. Docker on the Jenkins agent
The Jenkins agent that runs the pipeline must have Docker installed and accessible.
2. Add credentials in Jenkins
Go to Manage Jenkins → Credentials → Global → Add Credentials and add the following as Secret text credentials:
| Credential ID | Value |
|---|---|
CJ_SERVICE_ACCOUNT_KEY | Your fore ai service account key |
CJ_TEST_ID | ID of the test to run (for single-test pipelines) |
CJ_TEST_SUITE_ID | ID of the test suite to run (for suite pipelines) |
note
Make sure there are no leading or trailing spaces in credential values - these will cause authentication failures.
Run a single test
pipeline {
agent any
stages {
stage('Run fore ai Test') {
steps {
withCredentials([
string(credentialsId: 'CJ_SERVICE_ACCOUNT_KEY', variable: 'SERVICE_ACCOUNT_KEY'),
string(credentialsId: 'CJ_TEST_ID', variable: 'TEST_ID')
]) {
sh 'docker run --rm -e "INPUT_SERVICE_ACCOUNT_KEY=$SERVICE_KEY" -e "INPUT_TEST_ID=$TEST_ID" foreai/cj-action:latest'
}
}
}
}
}
Run a test suite
pipeline {
agent any
stages {
stage('Run fore ai Test Suite') {
steps {
withCredentials([
string(credentialsId: 'CJ_SERVICE_ACCOUNT_KEY', variable: 'SERVICE_ACCOUNT_KEY'),
string(credentialsId: 'CJ_TEST_SUITE_ID', variable: 'TEST_SUITE_ID')
]) {
sh 'docker run --rm -e "INPUT_SERVICE_ACCOUNT_KEY=$SERVICE_KEY" -e "INPUT_TEST_SUITE_ID=$SUITE_ID" -e "INPUT_WAIT_TIMEOUT_SECONDS=360" -e "INPUT_WEBSITE_URL_OVERRIDE=https://staging.my-app.com" -e "INPUT_PARAMS_OVERRIDE={\"param1\":\"value1\",\"param2\":\"value2\"}" foreai/cj-action:latest'
}
}
}
}
}
Available inputs
Pass each input as a Docker environment variable using -e "INPUT_<NAME>=<value>".
| Environment variable | Required | Default | Description |
|---|---|---|---|
INPUT_TEST_ID | No* | ID of the test to run. Provide either this or INPUT_TEST_SUITE_ID. | |
INPUT_TEST_SUITE_ID | No* | ID of the test suite to run. | |
INPUT_SERVICE_ACCOUNT_KEY | Yes | Your fore ai service account key. | |
INPUT_WAIT_TIMEOUT_SECONDS | No | 300 | Max seconds to wait for completion. Must be between 30 and 900. |
INPUT_WEBSITE_URL_OVERRIDE | No | Override the base website URL used during test execution. | |
INPUT_PARAMS_OVERRIDE | No | Override default parameter values. Must be a valid JSON string with string keys and values. | |
INPUT_BROWSER_TYPE_OVERRIDE | No | chromium | Browser engine: chromium, firefox, or webkit. |
INPUT_CREATE_ISSUE_ON_FAILURE | No | false | If true, creates an issue on test failure (requires additional token configuration). |
* Either INPUT_TEST_ID or INPUT_TEST_SUITE_ID must be provided.