Skip to main content

Creating Builds from Your CI/CD Pipeline

Instead of manually creating builds in TestCollab, automatically record builds from CI/CD pipeline using the TestCollab CLI. Use the tc createBuild command in your pipeline, how it works with Azure DevOps, GitHub Actions, and GitLab CI

Why Use the CLI?

Manually creating a build requires someone to open TestCollab and fill out a form.

Using the CLI means:

  • Builds are recorded automatically every time you deploy

  • The build includes deployment details from your pipeline (commit hash, branch, build number)

  • Your TestCollab Deployment card shows full traceability from code to testing

  • Subsequent pipeline steps can reference the build to link test results to it

  • No manual work required

Prerequisites

You need:

  1. TestCollab API key - generate this in your TestCollab profile settings

  2. Project ID - found in your project's settings

  3. TestCollab CLI installed

The tc createBuild Command

The basic command is:

tc createBuild --project PROJECT_ID --environment ENVIRONMENT_NAME

The CLI reads the version, commit, commit URL, repository URL and deployment URL from your CI provider's own environment. It detects Azure DevOps, GitHub Actions, GitLab CI, Bitbucket Pipelines, CircleCI and Jenkins, and logs which provider it matched. Pass a flag only to override what it detected.

Required Parameters

  • --project - your TestCollab project ID (number)

Optional Parameters

Parameter

What It Does

Example

--version

Version that was built or deployed. Defaults to the CI build number

v2.14.1

--environment

Environment where deployed

Production, Staging

--commit

Git commit hash. Defaults to the CI commit

abc123def456

--commit-url

Links to commit. Defaults to the CI commit URL

https://dev.azure.com/org1/proj1/_git/repo1/commit/dcf8d40435298cb6dd5a72ac1d81fb9

--deployment-url

Link to the pipeline run. Defaults to the CI run URL

https://deployments.company.com/12345

--repo-url

Link to the repo. Defaults to the CI repository

https://dev.azure.com/org1/proj1/_git/repo1

--notes

Description of changes

"Fixed login bug, added analytics"

--api-key

Your TestCollab API key (or use env var TESTCOLLAB_TOKEN)

--api-url

Your TestCollab API URL (defaults to production)

There is no --branch flag. Branch is not recorded on a build.

How It Works: Match-Then-Create

The CLI performs these actions:

  1. Search - it asks TestCollab, "Do you already have a build with version v2.14.1?"

  2. Match - if found, it reuses that build and verifies the details

  3. Create - if not found, it creates a new one

This prevents duplicate builds when your pipeline runs multiple times with the same version.

Output and the Build ID File

When successful, the CLI outputs:

Build "v2.14.1" (created, id 42) — Production
✅ Build recorded. Build ID: 42

A build that already exists reports (existing, id 42) instead of (created, id 42).

It also creates a file at tmp/tc_build containing:

TESTCOLLAB_BUILD_ID=42

Subsequent pipeline steps can read this file and use the build ID for linking test plans or test results.

Provider-Specific Examples

Azure DevOps Pipeline YAML

Add this to your pipeline's deployment job:

task: Bash@3
displayName: 'Record build in TestCollab'
env:
TESTCOLLAB_TOKEN: $(TESTCOLLAB_TOKEN) # Set as a pipeline variable
inputs:
targetType: 'inline'
script: |
tc createBuild \
--project 45 \
--environment "Production" \
--notes "Deployed to Production"

# Expose the build ID to later steps (Azure syntax)
BUILD_ID=$(cut -d= -f2 tmp/tc_build)
echo "##vso[task.setvariable variable=TESTCOLLAB_BUILD_ID]$BUILD_ID"

Then, in a later step, reference the build:

- task: Bash@3
displayName: 'Run tests against build'
inputs:
targetType: 'inline'
script: |
source tmp/tc_build
echo "Running tests against build $TESTCOLLAB_BUILD_ID"
# Your test execution command here

GitHub Actions Workflow YAML

Add this to your workflow's deployment job:

- name: Record build in TestCollab
env:
TESTCOLLAB_TOKEN: ${{ secrets.TESTCOLLAB_TOKEN }}
run: |
tc createBuild \
--project 45 \
--environment "Production" \
--notes "Deployed to Production"

cat tmp/tc_build >> $GITHUB_ENV

- name: Run tests against build
run: |
echo "Running tests against build $TESTCOLLAB_BUILD_ID"
# Your test execution command here

GitLab CI YAML

Add this to your .gitlab-ci.yml deployment job:

deploy_production:
stage: deploy
environment:
name: production
script:
- tc createBuild \
--project 45 \
--environment "Production" \
--notes "Deployed to Production"
- cat tmp/tc_build >> build.env
artifacts:
reports:
dotenv: build.env

Then reference it in a later job:

run_tests:
stage: test
needs:
- deploy_production
script:
- echo "Running tests against build $TESTCOLLAB_BUILD_ID"
# Your test execution command here

What You See in TestCollab

After running tc createBuild in your pipeline, the build appears in TestCollab with a Deployment Card on its detail page. Instead of just showing the version and environment, it shows:

  • Version - the software version

  • Commit - the Git commit hash; click to view on your repository

  • Repository - the repository URL; click to visit it

  • Deployed - the date and time of deployment

  • Release - the release this build is part of

  • Environment - the deployment environment

This provides full traceability from your code commit through to test results.

Integration with Test Result Reporting

The tc createBuild command works alongside the existing test result reporting workflow. In a complete testing pipeline, you use both:

  1. tc createBuild — Record the software version being deployed

  2. tc report — Upload automated test execution results against that version

This links your test results to a specific software version for full traceability from code to testing to deployment.

Complete Pipeline Example

Here's how both commands work together in an Azure DevOps pipeline:

stages:
- stage: Deploy
displayName: 'Deploy to Production'
jobs:
- job: DeployJob
steps:
# Step 1: Record the build version
- task: Bash@3
displayName: 'Record build in TestCollab'
env:
TESTCOLLAB_TOKEN: $(TESTCOLLAB_TOKEN)
inputs:
targetType: 'inline'
script: |
tc createBuild \
--project 45 \
--environment "Production"

# Save the build ID for later steps
BUILD_ID=$(cut -d= -f2 tmp/tc_build)
echo "##vso[task.setvariable variable=TESTCOLLAB_BUILD_ID]$BUILD_ID"

# Step 2: Deploy (your existing deployment steps here)
- task: Bash@3
displayName: 'Deploy application'
inputs:
targetType: 'inline'
script: |
# Your deployment commands here
echo "Deployed v$(Build.BuildNumber)"

- stage: Test
displayName: 'Run Tests'
dependsOn: Deploy
jobs:
- job: TestJob
steps:
# Step 3: Run automated tests and upload results
- task: Bash@3
displayName: 'Run tests and report results'
env:
TESTCOLLAB_TOKEN: $(TESTCOLLAB_TOKEN)
inputs:
targetType: 'inline'
script: |
# Create a test plan for this build. --build ties the plan to
# the version that was just deployed.
tc createTestPlan \
--project 45 \
--ci-tag-id 12 \
--assignee-id 34 \
--build "$TESTCOLLAB_BUILD_ID"
source tmp/tc_test_plan

# Run your tests. The mochawesome reporter writes its own JSON file.
npx mocha --reporter mochawesome

# Upload the results to that plan. The plan already carries the build,
# so --build is not needed here.
tc report \
--project 45 \
--test-plan-id "$TESTCOLLAB_TEST_PLAN_ID" \
--format mochawesome \
--result-file mochawesome-report/mochawesome.json

For more details on the tc report command and result file formats, see "Uploading Test Results Using TestCollab CLI" in the help documentation.

Next Steps

Once the build is created in TestCollab, you can:

  1. Link test plans to this build to track testing against it

  2. Use the build ID to report test results that are scoped to this deployment

  3. View the build's detail page to see full test results and coverage

See the "Linking Test Plans to a Build" guide for details.

Related Articles

Did this answer your question?