News Stay informed about the latest enterprise technology news and product updates.

Converting subtasks in JIRA with a Watir script

Whenever I do large data uploads into JIRA, I often find that I have a number of tickets that require a parent/child relationship. That is, some of my tickets get imported as tasks, and I want them to be subtasks. To solve this problem, I wrote a simple Watir script that will subtask out all my tickets for me after upload. There’s nothing that special about it, but it can be quite a time saver.

The only assumption I have in my script is that you’ll have a hyphen in your subtasks and no hyphens in your parent tasks. When I import data like this, I often following the pattern “<parent summary> – <child summary>” for my Summary fields when I import. For example, a parent ticket might be “Write a book on testing” and a couple of subtasks for that ticket might be “Write a book on testing – Chapter 1” and “Write a book on testing – Chapter 2.”

The first step is to setup a query of only the tickets you want to task and subtask. Often, this is as simple as creating a query in the Issue Navigator where you select the project, Issue Type, and whatever other compoents/values uniquely identify that subset of data. I’ll then sort by Summary, so my parent tickets will always be before my child tickets — again because of my naming convention.

Below, the link to that filter is where you start your browser in the second line of code. In the third line, I simply click on the first result returned. Then the code loops through all the tickets and establishes the parent/child relationships as needed.

require 'watir'
b = Watir::Browser.start(""), "KEY-2332").click

for i in (1..800)
if b.table(:index, 9).table(:index, 2).cells[1].text.split('-')[1] == nil then
ticket = b.url.split("/")[-1]
else, "Convert").click
b.text_field(:name, "parentIssueKey").set ticket
b.button(:name, "Next >>").click
b.button(:name, "Next >>").click
b.button(:name, "Finish").click
end, "Next >>").click

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.