integrate leapwork go with ci cd pipelines.md
Integrate Leapwork Go with CI/CD Pipelines
This guide shows how to run Leapwork Go tests from a CI/CD pipeline, wait for the result, and collect reports for later review.
What You Can Automate
A typical pipeline integration follows this sequence:
- Submit a performance test run to Leapwork Go.
- Capture the
runIdand polling URL from the API response. - Poll the run status until the run is complete.
- Download the generated reports.
- Mark the pipeline as passed or failed based on the result.
Integration Flow
CI/CD pipeline starts -> Call Leapwork Performance run API -> Receive runId and poll URL -> Poll status until Finished, Failed, or Stopped -> Download reports -> Pass or fail the pipeline
Prerequisites
Before you build the integration, make sure you have:
- Access to a Leapwork Go environment.
- An API key with permission to start and read integration runs.
- The asset IDs or names required for the test you want to execute.
- A CI/CD agent that can make outbound HTTPS calls to the Leapwork Go API.
- Permission in your pipeline environment to store secrets securely.
Authentication
Use an API key when calling Leapwork Go from your pipeline. Store the key in your CI/CD secret store and inject it into the job at runtime.
Example header:
Authorization: X-API-KEY
Step 1: Start a Test Run
Submit a request to the run endpoint.
POST /api/integration/runIntegration
Content-Type: application/json
Authorization: X-API-KEY
Example request body:
{
"timelineAssetId": "
A successful response returns identifiers and a URL you can use for polling.
Example response fields:
{
"timelineId": "
Step 2: Poll for Completion
Poll the status endpoint until the run reaches a terminal state.
During execution you may see statuses such as:
AuthenticatingPreparingRunning
Terminal states are:
FinishedFailedStopped
Your pipeline should keep polling while the run is still active, then stop when it reaches a terminal state.
Step 3: Download Reports
When the run is complete, download the report URLs returned by the API response.
Typical outputs include:
- Excel report
- AI analysis report
These can be published as pipeline artifacts so teams can review them after the build.
Optional: Stop a Run Early
If your pipeline times out or you need to cancel the execution, call the stop endpoint with the runId.
GET /api/integration/stopIntegration?runId=
Azure DevOps Example
The Azure DevOps pattern is usually:
- Store the API key as a secret pipeline variable.
- Run a script step to submit the test run.
- Parse the response and save the
runIdandpollResultUrl. - Run a second script step to poll until completion.
- Publish the downloaded reports as build artifacts.
Example pipeline shape:
trigger:
- main
pool:
vmImage: windows-latest
variables:
LEAPWORK_PERFORMANCE_BASE_URL: 'https:// -BaseUrl "$(LEAPWORK_PERFORMANCE_BASE_URL)"
-ApiKey "$(LEAPWORK_PERFORMANCE_API_KEY)" -TimelineId "$(LEAPWORK_PERFORMANCE_TIMELINE_ID)"
-TimelineName "$(LEAPWORK_PERFORMANCE_TIMELINE_NAME)" -ProjectId "$(LEAPWORK_PERFORMANCE_PROJECT_ID)"
-DataItemAssetId "$(LEAPWORK_PERFORMANCE_DATA_ITEM_ASSET_ID)" -DataItemName "$(LEAPWORK_PERFORMANCE_DATA_ITEM_NAME)"
-Role "$(LEAPWORK_PERFORMANCE_ROLE)" -UserCount "$(LEAPWORK_PERFORMANCE_USER_COUNT)" displayName: Start Leapwork Go run - powershell: | ./azure-devops/poll-integration-status.ps1
-BaseUrl "$(LEAPWORK_PERFORMANCE_BASE_URL)" -ApiKey "$(LEAPWORK_PERFORMANCE_API_KEY)"
-RunId "$(RunId)" -TrackItemIds "$(TrackItemIds)"
-TrackItemNames "$(TrackItemNames)" -PollResultUrl "$(PollResultUrl)"
-ExpectedRunTime "$(ExpectedRunTime)"
displayName: Wait for Leapwork Go result
- task: PublishBuildArtifacts@1
displayName: Publish Leapwork Go reports
condition: always()
inputs:
PathtoPublish: reports
ArtifactName: leapwork-performance-reports
Jenkins Example
The Jenkins pattern is similar:
- Store the API key in Jenkins credentials.
- Load the credential into the pipeline environment.
- Run a script to start the test.
- Poll until completion.
- Archive the downloaded reports.
Example pipeline shape:
pipeline {
agent any
environment {
LEAPWORK_PERFORMANCE_BASE_URL = 'https:// -BaseUrl "$env:LEAPWORK_PERFORMANCE_BASE_URL"
-ApiKey "$env:LEAPWORK_PERFORMANCE_API_KEY" -TimelineId "$env:LEAPWORK_PERFORMANCE_TIMELINE_ID"
-TimelineName "$env:LEAPWORK_PERFORMANCE_TIMELINE_NAME" -ProjectId "$env:LEAPWORK_PERFORMANCE_PROJECT_ID"
-DataItemAssetId "$env:LEAPWORK_PERFORMANCE_DATA_ITEM_ASSET_ID" -DataItemName "$env:LEAPWORK_PERFORMANCE_DATA_ITEM_NAME"
-Role "$env:LEAPWORK_PERFORMANCE_ROLE" -UserCount "$env:LEAPWORK_PERFORMANCE_USER_COUNT" ''' } } } stage('Wait for result') { steps { withCredentials([string(credentialsId: 'leapwork-performance-api-key', variable: 'LEAPWORK_PERFORMANCE_API_KEY')]) { powershell ''' $runOutput = Get-Content .\\run-output.json | ConvertFrom-Json .\\poll-integration-status.ps1
-BaseUrl "$env:LEAPWORK_PERFORMANCE_BASE_URL" -ApiKey "$env:LEAPWORK_PERFORMANCE_API_KEY"
-RunId "$($runOutput.RunId)" -TrackItemIds "$($runOutput.TrackItemIds)"
-TrackItemNames "$($runOutput.TrackItemNames)" -PollResultUrl "$($runOutput.PollResultUrl)"
-ExpectedRunTime "$($runOutput.ExpectedRunTime)"
'''
}
}
}
}
post {
always {
archiveArtifacts artifacts: 'reports/**', fingerprint: true, allowEmptyArchive: true
}
}
}
Attachments
Please open each link, copy the full file content, paste it into a local file, and save it with the original filename. Included attachments:
azure-pipelines.yml- azure-pipelines.ymlrun-integration.ps1- run-integration.ps1poll-integration-status.ps1- poll-integration-status.ps1Jenkinsfile-JenkinsfileREADME.txt- README.txt
Validation Checklist
After setup, confirm that your pipeline can:
- Authenticate successfully with the API key.
- Start a new performance run.
- Poll until the run reaches a terminal state.
- Download the expected reports.
- Fail the build when the run result is unsuccessful.
Troubleshooting
If the integration does not work as expected, check the following first:
- The base URL points to the correct Leapwork Go environment.
- The API key is valid and passed in the required header.
- Required IDs in the request payload belong to assets that exist in your environment.
- The build agent can reach the API endpoints over the network.
- The polling logic stops only on terminal statuses.