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
4,298,157
Community Members
 
Community Events
165
Community Groups

What are the ways to store value (variables) persistently in groovy?

I know about 

import com.onresolve.scriptrunner.runner.util.OSPropertyPersister

def pluginSettings = OSPropertyPersister.getPluginSettings()

def key = "key"
def value = "my-value"

// save value against key
pluginSettings.put(key, value)

// retrieve value for key
def savedValue = pluginSettings.get(key)

But is there any other way to store data for later use in scripts? For example suppose I have a counter which is incremented for a specific kind of issue and I want to read it later...

 

1 answer

Hi there,

I presume this data you wish to store is not in context of An issue or A project, but rather for the whole instance?

In that case, have you considered adding a table tot the Jira (or other accessible) database?

From groovy you could then access this data, this KB article should help you on your way:
https://scriptrunner.adaptavist.com/4.3.4/jira/recipes/misc/connecting-to-databases.html

Let me know if this helps!

 

Regards,

Jeroen

This is exactly what I am looking for. Is there a suggested way or guideline to add tables tot Jira database?

Hi,

Just creating tables in the Jira DB is strongly discouraged, since Jira will probably ignore these tables during upgrades etc ...
https://community.atlassian.com/t5/Jira-Core-questions/How-to-insert-a-custom-table-to-JIRA-DB/qaq-p/424568

A few options:

 

Regards,

Jeroen

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

155 views 1 3
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