Jenkins
Set up TestKase test reporting in your Jenkins pipelines.
Jenkins
Jenkins
Setup Steps
- Go to Manage Jenkins → Manage Credentials. Add "Secret text" credentials for
testkase-pat. - Add the reporting stage to your
Jenkinsfile. - Update the CLI flags to match your project.
- Run your pipeline.
Pipeline Template
pipeline {
agent any
environment {
TESTKASE_PAT = credentials('testkase-pat')
}
stages {
stage('Install') {
steps { sh 'npm ci' }
}
stage('Test') {
steps { sh 'npm test -- --reporter=junit --outputFile=test-results/junit.xml' }
}
}
post {
always {
sh '''
npx @testkase/reporter report \\
--token $TESTKASE_PAT \\
--project-id PRJ-1 \\
--org-id 1173 \\
--cycle-id TCYCLE-5 \\
--format junit \\
--results-file test-results/junit.xml \\
--build-id "$BUILD_NUMBER"
'''
}
}
}npm test -- --reporter=junit --outputFile=… is a placeholder, not a real command for most runners.
Replace it with the command that produces your framework's results file — e.g.
pytest --junitxml=test-results/junit.xml, npx playwright test, or mvn test — and set --format
to match. See the Test Frameworks guides for the
exact command and format per framework.
Keep this step in a single-quoted Groovy string (sh ''' ... '''), as the template above
does. Inside a double-quoted Groovy string (sh """ ... """) Groovy expands $TESTKASE_PAT
itself, so the credential is substituted into the command line before the shell ever sees it — where it
can surface in process listings and build logs. With single quotes the literal $TESTKASE_PAT reaches
the shell, which reads it from the environment that credentials() populated. The same applies to
$BUILD_NUMBER, which Jenkins also exports into the shell environment.
--cycle-id TCYCLE-5 above is a placeholder. The test cases you report on must already be linked to
the cycle you target. If they are not, the API rejects every result with Test case not linked with
this test cycle, the reporter exits 1, and this pipeline goes red on its first run. Either add those
test cases to the cycle first, or drop --cycle-id altogether and report into TCYCLE-1 — the Master
Cycle, which always contains every test case in the project.
