How to issue a JQL query in BPS for Jira

Visitas: 105

In this tutorial, we will look at a more advanced script. We will issue a JQL query against Jira and retrieve information.

This is an example of a very typical script that you might use to aggregate information or other queries from Jira to get issues. 

The first thing to do is to rename the script. 
In the Property Inspector rename the script to “jqlquery”.

The first part of the script is to import all the object classes that we need to use. These are provided by Jira.

Then we get components that are core for this script.
Line 6 is a parser for JQL query. 
Line 7 is the search service in order to issue the search. 
Line 8 is the Issue Manager is used in this case to get a new table issued, it is not used here but it is a way to showcase how we can do it. 
Line 9, the User is the way to get the Jira user that is executing the script. In this case we are using the user that has been authenticated.

Then the first step in line 11 is to get the query that we are going to execute

The text in red is JQL language. In this query we are going to get all the issues from this project, and where the assignee is equal to the current user. 

Next, we execute the query, under the current user. This is because in Jira, depending on the user rights, it will allow access to different Jira tasks and issues.

And after the user, query, it instructs to get ALL results without pagination. 

Once the search has been executed, we get the total number of issues.

We then print the key of that issue and the summary of the issue.

Let’s run the script. Click on the ‘Run Script’ button at the top of the window.

In the output tab in the tools section at the bottom, you can see that we have a total of 3 issues. 
The Key and Summary are listed for each issue.

As you can see it is quite easy to do complex things with scripts in Business Process Studio.
Thank you for following this tutorial, we hope you find this function very useful in your projects.

Esta pregunta es para comprobar si usted es un visitante humano y prevenir envíos de spam automatizado.