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

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

How to create and update custom fields option from a json file with ScriptRunner


one of our external teams feeds weekly a file with values ​​that we want to "synchronize" in a single select liste custom field.

This field is  is deposited on our server in {server}/home/deposit. 

The first step is to create the field with all the options. I know I can use the built-in script but if I can do that with console it's better for me.

The second step is to update weekly this field with the json file...
Does anyone have a sample script that would allow me to create and update this list from the file ?

Or can you just give me an example to bulk add options from a list that I can create directly in my script (to have a baseline) ? 

last question, how can I "open" my jsonfile that is on my server on a scriptrunner console ?

Best regards,



1 answer

0 votes
Ravi Sagar Community Leader Jan 13, 2021

Hi @David Coudron 

Let me try to help.

Reading a file

You can read a file like this. The location should be accessible on the server where Jira is installed by the user running Jira.

File file = new File("/opt/jira/home/scripts/file.json")

Parsing JSON

Try this.

JsonSlurper slurper = new JsonSlurper()
Map parsedJson = slurper.parseText(file)
//parsedJson will let you access your data
// or

To set custom field options

There are few possibilities. I would suggest take a look at this page and our script library where we have plenty of examples.

I hope it helps.


Hello Ravi,

Thanks for your answer !

I try to reading the file with your method and it's work.
But when I try to parse my json file I have the following error :

2021-01-19 19:09:32,105 ERROR [common.UserScriptEndpoint]: Script console script failed: groovy.lang.MissingMethodException: No signature of method: groovy.json.JsonSlurper.parseText() is applicable for argument types: ( values: [/home/user/depot/file.json] Possible solutions: parseText(java.lang.String), parse(, parse([B), parse([C), parse(, parse( at


Here my code : 

import groovy.json.JsonSlurper

File file = new File("/home/adminsii/depot/file.json")

JsonSlurper slurper = new JsonSlurper()
Map parsedJson = slurper.parseText(file)


Do you know what is wrong ?

Best regards,


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

344 views 3 14
Read article

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