Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

how to Run Curl command in Script runner

Hi ,

I want t create github branch from workflow  post function .

I am able to run it through server but I am getting below error while running in Script runner .


def url = '{"ref":"refs/heads/Scriptrunner_branch124","sha":"5z12347f551369e1ff3e176c55a8640ee9d7c16b"}'

def command = 'curl -X POST -H "Authorization: token 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" -d "$url"'


def proc = command.execute()


println "Process exit code: ${proc.exitValue()}"

println "Std Err: ${proc.err.text}"

println "Std Out: ${}"


I am getting below error 


org.codehaus.groovy.runtime.InvokerInvocationException: Cannot run program "curl": error=2, No such file or directory at Source) Caused by: Cannot run program "curl": error=2, No such file or directory at


Could you please help me to resolve this ?


2 answers

1 vote

In scriptrunner for jira server/datacenter, the scriptrunner console has access to the underlying operating system.

With that, you can access files directly, and issue any os commands.

That's what the "string".execute() method does. It rune the string command by the OS.

In cloud, that's not possible for various security reasons.

So you need to use the Unirest client available in scriptrunner for cloud.

I don't have a cloud instance to test with, but it should look something like this:

def payload = [
ref: "refs/heads/Scriptrunner_branch124",
sha: "5z12347f551369e1ff3e176c55a8640ee9d7c16b"
ef url = ""
def token = 'token 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'

def postResponse = post(url)
.header('Content-Type', 'application/json')
.header('Authorization', token)

Hi Peter ,

Thanks for your reply . 

i tried this script but getting below error . returned an error code: status: 422 - Unprocessable Entity body: java.lang.NullPointerException


I am not able to find what exactly wrong in script


Can you please help to rectify .




Hi @Peter-Dave Sheehan 

Additionally in Script it is showing below warning message .

  Can not find matching method io.github.openunirest.request.body.RequestBodyEnrity#asObject()


Do I need to import any package for this ?


Thanks ,


As I said before I don't have access to a cloud instance to test or debug this further.

You'll have to refer to the GitHub api documentation and the scriptrunner/unirest documentation.

You can try to change asObject() to asString().

But the 422 error likely means that github has some problem with the payload.

I'm affraid I can't provide any additional value.

0 votes

Hi @Pravin Awati 

ScriptRunner for Jira on server is different from Cloud where you have to do these automations by using Jira REST API.


hi @Ravi Sagar _Sparxsys_ 

Thanks for your reply .

But I am not looking for any API for Jira  , I want to create the branch from workflow postfunction in Jira for that i am using this curl command in script runner . is there any other way we can implement it ?




Suggest an answer

Log in or Sign up to answer

Atlassian Community Events