This guide shows how to integrate Jenkins with TestCollab using the TestCollab CLI (@testcollab/cli). After your tests run in a Jenkins pipeline, the CLI automatically uploads results to TestCollab so your team can track test execution without manual effort.
How It Works
Jenkins runs your tests and generates a report file (JUnit XML, Mochawesome JSON, etc.)
The TestCollab CLI creates a test plan in your project using
tc createTestPlanThe CLI uploads results to TestCollab using
tc report, matching test cases by ID
Prerequisites
A TestCollab account with test cases created in your project
A TestCollab API key (how to generate one)
A Jenkins instance with Node.js 18+ available (install via the NodeJS Plugin or pre-install on agents)
Test case IDs embedded in your test names (e.g.,
[TC-42] Login should succeed)
Step 1: Add Credentials in Jenkins
Store your TestCollab credentials in Jenkins. Go to Manage Jenkins → Credentials and add:
testcollab-token— a Secret text credential containing your TestCollab API key
You can set project-specific values (project ID, tag ID, assignee ID) either as Jenkins environment variables or directly in the pipeline script.
Step 2: Configure Your Jenkinsfile
Below are complete Jenkinsfile (Declarative Pipeline) examples for popular test frameworks.
Playwright (JUnit XML)
pipeline {
agent any
tools {
nodejs 'node-20'
}
environment {
TESTCOLLAB_TOKEN = credentials('testcollab-token')
TC_PROJECT_ID = '42'
TC_CI_TAG_ID = '10'
TC_ASSIGNEE_ID = '5'
}
stages {
stage('Install') {
steps {
sh 'npm ci'
sh 'npm install -g @testcollab/cli'
sh 'npx playwright install --with-deps'
}
}
stage('Create Test Plan') {
steps {
sh "tc createTestPlan --project ${TC_PROJECT_ID} --ci-tag-id ${TC_CI_TAG_ID} --assignee-id ${TC_ASSIGNEE_ID}"
script {
env.TESTCOLLAB_TEST_PLAN_ID = sh(script: "grep -oP '(?<=TESTCOLLAB_TEST_PLAN_ID=).*' tmp/tc_test_plan", returnStdout: true).trim()
}
}
}
stage('Run Tests') {
steps {
sh 'PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --reporter=junit || true'
}
}
stage('Upload Results') {
steps {
sh "tc report --project ${TC_PROJECT_ID} --test-plan-id ${TESTCOLLAB_TEST_PLAN_ID} --format junit --result-file results.xml"
}
}
}
post {
always {
archiveArtifacts artifacts: 'results.xml', allowEmptyArchive: true
}
}
}
Cypress (Mochawesome JSON)
pipeline {
agent any
tools {
nodejs 'node-20'
}
environment {
TESTCOLLAB_TOKEN = credentials('testcollab-token')
TC_PROJECT_ID = '42'
TC_CI_TAG_ID = '10'
TC_ASSIGNEE_ID = '5'
}
stages {
stage('Install') {
steps {
sh 'npm ci'
sh 'npm install -g @testcollab/cli'
}
}
stage('Create Test Plan') {
steps {
sh "tc createTestPlan --project ${TC_PROJECT_ID} --ci-tag-id ${TC_CI_TAG_ID} --assignee-id ${TC_ASSIGNEE_ID}"
script {
env.TESTCOLLAB_TEST_PLAN_ID = sh(script: "grep -oP '(?<=TESTCOLLAB_TEST_PLAN_ID=).*' tmp/tc_test_plan", returnStdout: true).trim()
}
}
}
stage('Run Tests') {
steps {
sh 'npx cypress run --reporter mochawesome --reporter-options reportDir=results,overwrite=false,html=false,json=true || true'
}
}
stage('Upload Results') {
steps {
sh "tc report --project ${TC_PROJECT_ID} --test-plan-id ${TESTCOLLAB_TEST_PLAN_ID} --format mochawesome --result-file results/mochawesome.json"
}
}
}
post {
always {
archiveArtifacts artifacts: 'results/**', allowEmptyArchive: true
}
}
}
pytest (JUnit XML)
pipeline {
agent any
environment {
TESTCOLLAB_TOKEN = credentials('testcollab-token')
TC_PROJECT_ID = '42'
TC_CI_TAG_ID = '10'
TC_ASSIGNEE_ID = '5'
}
stages {
stage('Install Python deps') {
steps {
sh 'pip install -r requirements.txt'
}
}
stage('Run Tests') {
steps {
sh 'pytest --junitxml=results.xml || true'
}
}
stage('Create Test Plan') {
steps {
sh "tc createTestPlan --project ${TC_PROJECT_ID} --ci-tag-id ${TC_CI_TAG_ID} --assignee-id ${TC_ASSIGNEE_ID}"
script {
env.TESTCOLLAB_TEST_PLAN_ID = sh(script: "grep -oP '(?<=TESTCOLLAB_TEST_PLAN_ID=).*' tmp/tc_test_plan", returnStdout: true).trim()
}
}
}
stage('Upload Results') {
steps {
sh "tc report --project ${TC_PROJECT_ID} --test-plan-id ${TESTCOLLAB_TEST_PLAN_ID} --format junit --result-file results.xml"
}
}
}
post {
always {
archiveArtifacts artifacts: 'results.xml', allowEmptyArchive: true
}
}
}
Java / Maven (JUnit XML)
pipeline {
agent any
tools {
maven 'maven-3.9'
nodejs 'node-20'
}
environment {
TESTCOLLAB_TOKEN = credentials('testcollab-token')
TC_PROJECT_ID = '42'
TC_CI_TAG_ID = '10'
TC_ASSIGNEE_ID = '5'
}
stages {
stage('Install CLI') {
steps {
sh 'npm install -g @testcollab/cli'
}
}
stage('Run Tests') {
steps {
sh 'mvn test -Dmaven.test.failure.ignore=true'
}
}
stage('Create Test Plan') {
steps {
sh "tc createTestPlan --project ${TC_PROJECT_ID} --ci-tag-id ${TC_CI_TAG_ID} --assignee-id ${TC_ASSIGNEE_ID}"
script {
env.TESTCOLLAB_TEST_PLAN_ID = sh(script: "grep -oP '(?<=TESTCOLLAB_TEST_PLAN_ID=).*' tmp/tc_test_plan", returnStdout: true).trim()
}
}
}
stage('Upload Results') {
steps {
sh "tc report --project ${TC_PROJECT_ID} --test-plan-id ${TESTCOLLAB_TEST_PLAN_ID} --format junit --result-file target/surefire-reports/TEST-*.xml"
}
}
}
post {
always {
junit 'target/surefire-reports/*.xml'
archiveArtifacts artifacts: 'target/surefire-reports/*.xml', allowEmptyArchive: true
}
}
}
How the Pipeline Works
|| true(or-Dmaven.test.failure.ignore=truefor Maven) ensures the pipeline continues to the upload stage even when tests fail — this is important so that failed results are still reported to TestCollab.credentials('testcollab-token')securely injects your TestCollab API key as theTESTCOLLAB_TOKENenvironment variable. The CLI reads this automatically.tc createTestPlancreates a new test plan in TestCollab and writes the plan ID totmp/tc_test_plan.grep+returnStdoutextracts theTESTCOLLAB_TEST_PLAN_IDfrom the file and sets it as a Jenkins environment variable for subsequent stages.tc reportparses the test report file and updates the test case results in TestCollab.
Freestyle Project
If you use a freestyle project instead of a pipeline, add an Execute shell build step with:
npm install -g @testcollab/cli
# Create test plan
tc createTestPlan --project $TC_PROJECT_ID --ci-tag-id $TC_CI_TAG_ID --assignee-id $TC_ASSIGNEE_ID
source tmp/tc_test_plan
# Run your tests (example: Playwright)
PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --reporter=junit || true
# Upload results
tc report --project $TC_PROJECT_ID --test-plan-id $TESTCOLLAB_TEST_PLAN_ID --format junit --result-file results.xml
Set TESTCOLLAB_TOKEN, TC_PROJECT_ID, TC_CI_TAG_ID, and TC_ASSIGNEE_ID as environment variables in Manage Jenkins → System → Global properties → Environment variables, or inject them using the Credentials Binding Plugin.
Custom API URL
By default the CLI connects to https://api.testcollab.io. If your TestCollab instance uses a different API URL, add the --api-url flag to both tc createTestPlan and tc report commands:
tc createTestPlan --project $TC_PROJECT_ID --ci-tag-id $TC_CI_TAG_ID --assignee-id $TC_ASSIGNEE_ID --api-url https://your-api-url.example.com
tc report --project $TC_PROJECT_ID --test-plan-id $TESTCOLLAB_TEST_PLAN_ID --format junit --result-file results.xml --api-url https://your-api-url.example.com
Mapping Test Case IDs
For the CLI to match test results with TestCollab test cases, include the test case ID in your test names. Supported patterns:
TC-123id-123testcase-123
For example, in Playwright:
test('TC-1045 Login with valid credentials', async ({ page }) => {
// test code
});
Troubleshooting
Pipeline fails at upload stage — verify that your credentials are configured correctly and that the API key has not expired.
Node.js not found — install the NodeJS Plugin and configure a Node.js installation in Manage Jenkins → Tools, then reference it with
tools { nodejs 'node-20' }in your pipeline.No results updated in TestCollab — ensure your test names include a recognized test case ID pattern (TC-123, id-123, or testcase-123).
Authentication error — check that
TESTCOLLAB_TOKENis set correctly. If using a custom API URL, make sure to include the--api-urlflag.
For the full CLI reference, see Uploading Test Results Using TestCollab CLI.
For any queries or feedback, contact us at [email protected].
