This guide walks you through setting up a Bitbucket Pipeline that automatically creates a test plan in TestCollab, runs your tests, and uploads the results — all using the TestCollab CLI.
Prerequisites
A TestCollab API token (from Account Settings → API Tokens)
Your TestCollab project ID
A tag applied to the test cases you want to run in CI (note the tag ID)
The assignee user ID for pipeline executions
Test case IDs embedded in your test names (e.g.,
[TC-42] Login should succeed)
Step 1: Add Repository Variables
Go to your Bitbucket repository → Repository settings → Pipelines → Repository variables and add the following variables. Mark TESTCOLLAB_TOKEN as Secured to keep it hidden in logs.
Variable Name | Value | Secured |
| Your TestCollab API token | Yes |
| Your TestCollab project ID (number) | No |
| Tag ID for CI test cases (number) | No |
| Assignee user ID (number) | No |
Step 2: Create the Pipeline Configuration
Create a bitbucket-pipelines.yml file in the root of your repository. Below are complete examples for common test frameworks.
Example: Playwright (JUnit XML)
image: node:22
pipelines:
default:
- step:
name: Run Tests & Upload to TestCollab
caches:
- node
script:
- npm ci
- npm install -g @testcollab/cli
- npx playwright install --with-deps chromium
- tc createTestPlan --project $TC_PROJECT_ID --ci-tag-id $TC_CI_TAG_ID --assignee-id $TC_ASSIGNEE_ID
- source tmp/tc_test_plan
- PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --reporter=junit || true
- tc report --project $TC_PROJECT_ID --test-plan-id $TESTCOLLAB_TEST_PLAN_ID --format junit --result-file ./results.xml
Example: Cypress (Mochawesome JSON)
image: cypress/included:latest
pipelines:
default:
- step:
name: Run Tests & Upload to TestCollab
caches:
- node
script:
- npm ci
- npm install -g @testcollab/cli
- tc createTestPlan --project $TC_PROJECT_ID --ci-tag-id $TC_CI_TAG_ID --assignee-id $TC_ASSIGNEE_ID
- source tmp/tc_test_plan
- npx cypress run --reporter mochawesome --reporter-options reportDir=results,overwrite=false,html=false,json=true || true
- tc report --project $TC_PROJECT_ID --test-plan-id $TESTCOLLAB_TEST_PLAN_ID --format mochawesome --result-file ./results/mochawesome.json
Example: pytest (JUnit XML)
image: python:3.12
pipelines:
default:
- step:
name: Run Tests & Upload to TestCollab
script:
- pip install -r requirements.txt
- curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
- apt-get install -y nodejs
- npm install -g @testcollab/cli
- tc createTestPlan --project $TC_PROJECT_ID --ci-tag-id $TC_CI_TAG_ID --assignee-id $TC_ASSIGNEE_ID
- source tmp/tc_test_plan
- pytest --junitxml=results.xml || true
- tc report --project $TC_PROJECT_ID --test-plan-id $TESTCOLLAB_TEST_PLAN_ID --format junit --result-file ./results.xml
Example: Java / Maven (JUnit XML)
image: maven:3.9-eclipse-temurin-21
pipelines:
default:
- step:
name: Run Tests & Upload to TestCollab
caches:
- maven
script:
- curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
- apt-get install -y nodejs
- npm install -g @testcollab/cli
- tc createTestPlan --project $TC_PROJECT_ID --ci-tag-id $TC_CI_TAG_ID --assignee-id $TC_ASSIGNEE_ID
- source tmp/tc_test_plan
- mvn test || true
- tc report --project $TC_PROJECT_ID --test-plan-id $TESTCOLLAB_TEST_PLAN_ID --format junit --result-file ./target/surefire-reports/TEST-*.xml
How It Works
Each pipeline step follows the same three-step pattern:
Create test plan —
tc createTestPlancreates a new test plan in TestCollab containing all test cases tagged with your CI tag. It writes the plan ID totmp/tc_test_plan.Source the plan ID —
source tmp/tc_test_planloadsTESTCOLLAB_TEST_PLAN_IDas an environment variable for the rest of the script.Upload results —
tc reportparses your test output and updates each test case execution in the plan.
The || true after the test command ensures the pipeline continues to the upload step even when tests fail, so you always get results in TestCollab.
Branch-Specific Pipelines
You can run tests on specific branches instead of every push:
pipelines:
branches:
main:
- step:
name: Run Tests & Upload to TestCollab
image: node:22
script:
- npm ci
- npm install -g @testcollab/cli
- npx playwright install --with-deps chromium
- tc createTestPlan --project $TC_PROJECT_ID --ci-tag-id $TC_CI_TAG_ID --assignee-id $TC_ASSIGNEE_ID
- source tmp/tc_test_plan
- PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --reporter=junit || true
- tc report --project $TC_PROJECT_ID --test-plan-id $TESTCOLLAB_TEST_PLAN_ID --format junit --result-file ./results.xml
develop:
- step:
name: Run Tests & Upload to TestCollab
image: node:22
script:
- npm ci
- npm install -g @testcollab/cli
- npx playwright install --with-deps chromium
- tc createTestPlan --project $TC_PROJECT_ID --ci-tag-id $TC_CI_TAG_ID --assignee-id $TC_ASSIGNEE_ID
- source tmp/tc_test_plan
- PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --reporter=junit || true
- tc report --project $TC_PROJECT_ID --test-plan-id $TESTCOLLAB_TEST_PLAN_ID --format junit --result-file ./results.xml
Test Case ID Mapping
The CLI matches results to TestCollab test cases by looking for ID patterns in your test names:
[TC-42] Login should succeedTC-42 Login should succeedLogin should succeed id-42Login should succeed testcase-42
All patterns are case-insensitive. See the main CLI documentation for full details on ID patterns, configuration support, and troubleshooting.
EU Region
If your TestCollab account is on the EU region, add --api-url https://api-eu.testcollab.io to both the tc createTestPlan and tc report commands.
Troubleshooting
Results not uploading
Check that
TESTCOLLAB_TOKENis set correctly in repository variables and marked as SecuredVerify the result file path matches what your test framework actually outputs
Make sure the
--formatflag matches your output format (junitormochawesome)
Test cases not matched
Ensure your test names include a TestCollab ID pattern (e.g.,
[TC-42])Verify the test cases are tagged with the CI tag and assigned to the correct user in the test plan
Pipeline fails at npm install
If using a non-Node Docker image (e.g., Python, Java), you need to install Node.js first — see the pytest and Maven examples above
Alternatively, use a Node base image and install other runtimes as needed
