Can I call a rest api as a specific user in a scripted field?


I'm trying to get git tag information for a ticket and surface that information for JQL queries using scriptrunner scripted fields. My JIRA instance has the add-on "git integration for JIRA" which provides an api to query the tags:


I would like to be able to call this as a specific user on the system, but am not sure if this can be done within a scripted field.

What I have so far:

import org.apache.http.HttpResponse

def http = new HTTPBuilder("")
try {
http.get( path : "/rest/gitplugin/1.0/issuegitdetails/issue/${issue.key}/tag" ) { response, reader ->
assert response instanceof HttpResponse
log.warn "response status: ${response.statusLine}"
log.warn "body: ${reader}"
catch (e) {
log.warn e

return "git tags here"

How can I update the code above to call the api as a specific user? 

Can I cache the result until an event is fired (a specific workflow transition)?



1 answer

0 vote

Hi Matt,

I would start with Adaptavists documentation on Jelly Migration that has a couple examples where users were authenticated in code.

Next, there are a couple Community posts where I have seen some examples in the past of using the user in the body request:

def body_req = [
 "user": user,

In addition, I have also seen an example in the post Solved: Unable to run a groovy script as a service using script runner:

To run as a script (that saved a a file) in JIRA serivce, you need to authenticate the user that's running the service:
def AuthContext=ComponentAccessor.getJiraAuthenticationContext()
Good thing is, you don't need to supply the user's password.

Take a look at both of the resources and see which one works for you. 



Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,315 views 14 20
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot