Execute Script on Jira restart

We are in the process of implementing the environment variable concept as described here : Store all Environment Specific Variables

So, how do we set up the code so that it class file runs every time we restart jira.

There is no concept of running a class file - if you reference the class it will be recompiled when jira starts.

There are two methods there, one is using a java class, and one a yaml file (and java class). Which method are you using, and is there something that is not working?

the one with yaml since we are going to store the credentials that will be used to request the authentication token from azure. this is just a concept that we are exploring. Since SR4J (REsources) currently doesn’t support pulling data from Rest Api URL similar to Nfeeed

Since SR4J (REsources) currently doesn’t support pulling data from Rest Api URL

Hey… we do support pulling data from a REST API, the field to use is the “custom picker”. There are a few examples at Custom Picker.

the one with yaml since we are going to store the credentials

you could store credentials with either method, but both cases should work after restarting without running anything.

didnt realise the custom picker option :slight_smile:

On the other part the alternative we are looking at using Nfeed (elements connect … not a vary popular option since we are try to sunset it).

Try the custom picker option… I have never looked at nfeed to be honest. You can do the same authorisation in the script.

the custom picker was really helpful. thanks @jechlin.now we are stuck with importing the correct libraries :frowning: we have this code that keep failing

// https://mvnrepository.com/artifact/com.microsoft.azure/msal4j @Grapes(
@Grab(group=‘com.microsoft.azure’, module=‘msal4j’, version=‘1.8.1’)
)

not use if this works in scriptrunner. if it works, is there any additional setup needed to use the Grapes module.

Difficult to know because the code is mangled and you haven’t said how it’s failing. This worked for me

@Grab(group = 'com.microsoft.azure', module = 'msal4j', version = '1.8.1')
def x = 1

But your server needs proxy access, and you might need to configure Ivy. Have a look at Dependency management with Grape.

If that doesn’t work as far as I remember you can put the jar in WEB-INF/lib and restart.