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 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

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

Marketplace Partner Spotlight: AppLiger

This month the spotlight is on AppLiger. We caught up with Pavel Pavlovsky, CEO and Product Manager, to learn how the company started and what fuels the team's creativity.    Atlassian:...

375 views 0 7
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