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:

  1. Submit a performance test run to Leapwork Go.
  2. Capture the runId and polling URL from the API response.
  3. Poll the run status until the run is complete.
  4. Download the generated reports.
  5. 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:

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": "", "timelineName": "Smoke baseline", "projectId": "", "dataItemAssetId": "", "dataItemName": "Checkout workload", "role": "loadUser", "userCount": 50, "trackItems": [] }

A successful response returns identifiers and a URL you can use for polling.

Example response fields:

{ "timelineId": "", "runId": "", "status": "Preparing", "plannedRunTime": "00:10:00", "estimatedVum": 12, "trackItems": [], "pollResultUrl": "https:///getTimelineStatus?runId=" }

Step 2: Poll for Completion

Poll the status endpoint until the run reaches a terminal state.

During execution you may see statuses such as:

Terminal states are:

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:

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= Authorization: X-API-KEY

Azure DevOps Example

The Azure DevOps pattern is usually:

  1. Store the API key as a secret pipeline variable.
  2. Run a script step to submit the test run.
  3. Parse the response and save the runId and pollResultUrl.
  4. Run a second script step to poll until completion.
  5. Publish the downloaded reports as build artifacts.

Example pipeline shape:

trigger: - main pool: vmImage: windows-latest variables: LEAPWORK_PERFORMANCE_BASE_URL: 'https://' LEAPWORK_PERFORMANCE_TIMELINE_ID: '' LEAPWORK_PERFORMANCE_TIMELINE_NAME: 'Smoke baseline' LEAPWORK_PERFORMANCE_PROJECT_ID: '' LEAPWORK_PERFORMANCE_DATA_ITEM_ASSET_ID: '' LEAPWORK_PERFORMANCE_DATA_ITEM_NAME: 'Checkout workload' LEAPWORK_PERFORMANCE_ROLE: 'loadUser' LEAPWORK_PERFORMANCE_USER_COUNT: '50' steps: - checkout: self - powershell: | ./azure-devops/run-integration.ps1 -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:

  1. Store the API key in Jenkins credentials.
  2. Load the credential into the pipeline environment.
  3. Run a script to start the test.
  4. Poll until completion.
  5. Archive the downloaded reports.

Example pipeline shape:

pipeline { agent any environment { LEAPWORK_PERFORMANCE_BASE_URL = 'https://' LEAPWORK_PERFORMANCE_TIMELINE_ID = '' LEAPWORK_PERFORMANCE_TIMELINE_NAME = 'Smoke baseline' LEAPWORK_PERFORMANCE_PROJECT_ID = '' LEAPWORK_PERFORMANCE_DATA_ITEM_ASSET_ID = '' LEAPWORK_PERFORMANCE_DATA_ITEM_NAME = 'Checkout workload' LEAPWORK_PERFORMANCE_ROLE = 'loadUser' LEAPWORK_PERFORMANCE_USER_COUNT = '50' } stages { stage('Start Leapwork Go run') { steps { withCredentials([string(credentialsId: 'leapwork-performance-api-key', variable: 'LEAPWORK_PERFORMANCE_API_KEY')]) { powershell ''' .\run-integration.ps1 -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:

Validation Checklist

After setup, confirm that your pipeline can:

Troubleshooting

If the integration does not work as expected, check the following first: