Automatic Creation of Defect

Rohit Singh June 30, 2014

Dear Atlassian's,

I am working upon a project in which i have a requirement to automatically create defects using scripting.

My question is to is there any guide which could help me to achieve the task and What all attributes exposed to user(for e.g. can i post attachments, link jira defect to other existing Jira defects.)

your views on above vital to me, please do share your thoughts.

Regards, Rohit

Rohit.Singh@egonzehnder.com

+919560553033

4 answers

0 votes
Rohit Singh July 7, 2014

Hi Paresh,

The code below is not returning the desired result:

Unable to post defect

***********************************************************

Dim restReq, url

Set restReq = CreateObject("Microsoft.XMLHTTP")

username = "abc"

password = "xyz"

url = "http://10.0.51.30:8080/secure/Dashboard.jspa?os_username=" & username & "&os_password=" & password & ""

restReq.open "POST", url, False

restReq.setRequestHeader "Content-Type", "application/json"

postdata = "{""fields"": { ""project"":{ ""key"": ""Orchestra Mobile"" },""summary"": ""Test Automation"", ""issuetype"": {""name"":""Task""} }}"

restReq.send postdata

***********************************************************
restReq.responseText shows response login/dashboard page
0 votes
Rohit Singh July 2, 2014

Hi Paresh,

Thanks for your valuable information. I hope this will do.

But i have concern how can i find Syntax of the 'postdata' parameters such as priority, affected version/s etc.

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 2, 2014

JIRA Command Line Interface (CLI) is an alternative is you want to minimize development costs.

Rohit Singh July 2, 2014

Thanks Bob.

This give the fair idea about Methods and Parameters but still i want to know how can i find syntax for parameters. Just want to be sure before creating automatic defects as i have to work upon live environment for test.

Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 2, 2014

The action and parameter reference is found here. Specific parameters will depend on what you want to do. A simple example is:

--action createIssue --project XXX --type Bug --summary "My summary"

I recommend creating a test project to play with so you can clean it up later.

Rohit Singh July 9, 2014

I have downloaded __ cli-plugin-jira-3.9.0.obr pluggin but unable to install it.

Can you help me out.

Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2014

From these discussions, you want the JIRA Command Line Interface (CLI) client available from the Marketplate Get It Now link. Follow the installation instrucutions - Installation and Use.

0 votes
Paresh Gandhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 2, 2014

You can call below code in you project.

Save below code in .vbs file and execute the vbs file accordinly. You need to further investigate how you can change parameters, add attachment etc.

You need to enable rest api in jira if not already.

Dim restReq, url
Set restReq = CreateObject("Microsoft.XMLHTTP")
username = "<yourusername>"
password = "yourpassword>"
url = "https://jiraurl/rest/api/2/issue?os_username=" & username & "&os_password=" & password & ""
msgbox url
restReq.open "POST", url, false
restReq.setRequestHeader "Content-Type", "application/json"
postdata = "{""fields"": { ""project"":{ ""key"": ""projectket"" },""summary"": ""Created via rest api"", ""customfield_10301"": {""name"":""it is group picker single field""} ,""priority"": {""name"":""Minor""} ,""description"": ""Created via rest api"", ""issuetype"": {""name"": ""type of issue"" }}}"
restReq.send postdata
Msgbox restReq.responseText

Rohit Singh July 7, 2014

Hi Paresh,

The code below is not returning the desired result:

Unable to post defect

***********************************************************

Dim restReq, url

Set restReq = CreateObject("Microsoft.XMLHTTP")

username = "abc"

password = "xyz"

url = "http://10.0.51.30:8080/secure/Dashboard.jspa?os_username=" & username & "&os_password=" & password & ""

restReq.open "POST", url, False

restReq.setRequestHeader "Content-Type", "application/json"

postdata = "{""fields"": { ""project"":{ ""key"": ""Orchestra Mobile"" },""summary"": ""Test Automation"", ""issuetype"": {""name"":""Task""} }}"

restReq.send postdata

***********************************************************
restReq.responseText shows response login/dashboard page
Paresh Gandhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2014

what is the error

Rohit Singh July 9, 2014

I have not received any error but received a responseText

as screenshot below: And No defect is reported

Rohit Singh July 9, 2014

ResponseText is just returning the URL response, defect is not reported.

Paresh Gandhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2014

You are using wrong URL.

change it to

url = "https://10.0.51.30:8080/rest/api/2/issue?os_username=" & username & "&os_password=" & password & ""

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events