It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Querying Tempo specific information from another issue within JIRA: what would be the best strategy?

Rina Nir Solutions Partner Jun 03, 2014

Hi,

Using the TEMPO Plugin for reporting work on an issue A. We use the native JIRA field as well as "billed hours" field (which is TEMPO specific).

Within issue B we would like to display within a text field all the worklogs of issue A, and also have a calculated field showing the sum of billed hours of issue A.

Being rather newbie to the many options I am not sure if the best strategy would be to:

1) Use a scriptrunner field with REST API?

2) Implement a plugin which will access the "not public but existing" TEMPO REST API

3) Implement a plugin which will access the official TEMPO servlets? I think this should be doable but I am not sure which plug-in type I should use for this purpose and could not find any example providing clues on how to do it.

4) anyt other way?

Any leads and recommendations would be very much appreciated,

Rina

2 answers

1 accepted

0 votes
Answer accepted
Rina Nir Solutions Partner Jul 22, 2014

After implementing a solution to the above with Groovy (Script Runner), I am sharing the bones of it here:

1) The script accesses TEMPO through the TEMPO public API (service based API) . This is done using curl. BTW: this means that the same method may be used to query between two different JIRA systems- if that is required:

tempoParams="&format=xml&addBillingInfo=true&addIssueSummary=true&addParentIssue=true&addIssueDetails=true&dateFrom="+dateFrom+"&dateTo="+dateTo+"&issueKey="+linkedKeyAndSubtasks[i]processStr="curl -X GET http://"+systemURL+"/plugins/servlet/tempo-getWorkLog/?tempoApiToken="+token+tempoParamsdefprocess=processStr.execute()process.waitFor()

Note that using the TEMPO API is required only if you need to obtain TEMPO specific 
fields (such as the Billing info). If you just need the simple JIRA worklogs use the 
JIRA API.

2) The data which is obtained through the TEMPO service can be parsed using Groovy's 
xml parser:
	def worklogs = new XmlParser().parseText(process.text)
	worklogs.worklog.each{ ......
defentity=it
 totalBilled+=entity.billed_hours.text().toDouble()

}

3) Once updating the target custom field with the total billing information, be sure to
do the necessery for storing it to the database (thanks to some good answers I found here :
 
MutableIssue myIssue = issue

.............
//Update hoursSummaryStringCustomFieldhoursSummaryString=customFieldManager.getCustomFieldObjectByName(hoursSummaryStringFieldName)myIssue.setCustomFieldValue(hoursSummaryString,billingStr)Map<String,ModifiedValue>modifiedFields1=myIssue.getModifiedFields()FieldLayoutItemfieldLayoutItem1=ComponentManager.getInstance().getFieldLayoutManager().getFieldLayout(myIssue).getFieldLayoutItem(hoursSummaryString)DefaultIssueChangeHolderissueChangeHolder1=newDefaultIssueChangeHolder()finalModifiedValuemodifiedValue1=(ModifiedValue)modifiedFields1.get(hoursSummaryString.getId())hoursSummaryString.updateValue(fieldLayoutItem1,myIssue,modifiedValue1,issueChangeHolder1)

 
4) For our implementation, this script was added as a postfunction.

0 votes

Hi Rina

I don't understand the use case, why would you want to sum up worklogs and billed hours for issue A to display in a different issue?

1) I am not familiar with the script runner - so I don't know how you would use that in this case.

2) There is currently no REST API in Tempo to get billed hours per issue but that would definitely be the recommended solution I think if it existed :).

3) You can implement a plugin to do this. You should go through the JIRA dev documentation to figure out how to proceed. https://developer.atlassian.com/display/JIRADEV/JIRA+Plugin+Guide There are different ways to add data to the JIRA issue view. You could use the 'issue tab panel' or 'web panel' modules.

Hope this helps

Kristín

Rina Nir Solutions Partner Jul 21, 2014

In regards to the use case: The idea is to summarize the hours of many issues and prepare for invoicing withing an "invoicing" JIRA project. The "invoicing" project has different access rights and thus makes sense to seperate it from the "main" project.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Off-topic

Disney Live Action Reboots: Are you for or against?

Happy Friday Everyone! Today marks the international release of Disney's live action version of the animated classic Aladdin. I know that this movie was met with some controversy of over cast...

167 views 21 9
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you