How to create Jira bug for failed flow of Leapwork using PowerShell script
How to create Jira bug for failed flow of Leapwork using PowerShell script
Introduction
JIRA is a well-known tool in the market and is used for bug tracking, issue tracking, and project management. Leapwork offers integration with Jira by automatically creating bugs in JIRA when automation flows in Leapwork fails.
Leapwork Automation Platform comes with REST API, allowing any third party system to run automation flows on the platform and to retrieve the results. Similarly, we have Jira's REST API for creating bugs.
As part of the integration, we have a Windows Powershell script that runs a pre-defined Leapwork run list, polls for the results until they are available, and then loops through all failed cases and creates bugs in JIRA as appropriate using API's.
Create a bug in Jira
Generate an AccessKey from Leapwork Studio > Settings >Add Key.
Replace the generated key with Accesskey value
$headers.Add("AccessKey"," **<ADD THE API KEY>**")
Enter the Leapwork API URL.
Get your schedule name from Leapwork Studio->Runlist->Expand Runlist and replace it with schedule name.
#Run the LEAPWORK schedule "SmokeRunSchedule" and get the results.
$runResult = RunScheduleAndGetResults("SmokeRunSchedule")
Create an API token for Jira. Then enter the Jira Username: Jira API Token as highlighted below. To generate the Jira API token, refer: Create Jira API Token
Create a project in Jira where you want bugs to be created and replace it with key-value
# Create json issue.
$body = '{ "fields": { "project": { "key": "<PROJECT KEY>" }, "summary": "' + $bugTitle + '", "description": "' + $bugDescription + '", "issuetype": { "name": "Bug" } } }
- Enter the Jira instance URL.
# Create bug.
Invoke-RestMethod -Headers $header -Method Post -Body $body "< **JIRA INSTANCE URL>**/rest/api/2/issue/"
After running the PowerShell script, the schedule will be executed and for failed flows, a bug will be logged in Jira.
For any clarification, contact our Priority Support.