Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to store JSON in Jira or use my own built-in variables

Andrew Striletskyi
Contributor
June 26, 2018

Hello everyone. I want to store my JSON data in Jira and after that use this data in Groovy scripts. Or simply create built-in variable in Jira and use this variable in Groovy script. How to implement this situation? (or use other methods). I known about Bamboo , but I want to use other methods

1 answer

1 accepted

0 votes
Answer accepted
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 26, 2018

Hello @Andrew Striletskyi

You can store json on file system under jira_home directory and get it like this

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.util.JiraHome
import groovy.json.JsonSlurper


String s = ComponentAccessor.getComponentOfType(JiraHome.class).getHome()
def jsonfile = new File(s+"/scripts/data/youejson.json")
def json = new JsonSlurper().parseText(jsonfile.text)

Map jsonRes = (Map) json
Map vendors = (Map) jsonRes.get('keyelement')

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events