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

Best practice for managing scripts

Hello all,

Good Morning. Hope you all are doing well :)

What is the best way/practice to manage the scripts conditions, validators, and post functions in Jira?

Whether we should apply the inline scripts to workflow condition, validator, and post function directly or add it to server <JIRA_HOME>/scripts directory.

As the script runner has been provided a new script editor function using which we can directly edit the script which we have added to the scripts directory of the server.

If you say, add it to server <JIRA_HOME>/scripts directory then what will be naming convention we should use?

Any suggestions will be appreciated!!

1 comment

My plan is to eventually convert all inline scripts that are more than 2/3 lines into script files.

The advantage of inline scripts is that the script is stored in your database and embedded into workflow xml. So it is included in backup, db migration, workflow migration and it gets appropriately picked up by add-ons like Configuration Manager.

The disadvantage of inline scripts is that when you get errors thrown in the log, you will get a generic "script123.groovy:53". Not always obvious.

The reason I'm heading towards the file model is to have more robust change management. I will store all my script files in a bitbucket repository and eventually set up some automation with bamboo to deploy scripts from dev to test to prod.

Also, I like being able to search for specific code snippets across all previously written scripts. 

As for file structure, that will greatly depend on your use cases and the number of files you have. But plan it out in advance, because changing it later will require you to go through all you scriptrunner configurations to update the file paths.

Your options are:

  1. flat, all files in the scripts directory
  2. simple 1 layer: 
    • behaviours
    • scriptedFields
    • validators
    • conditions
    • postFunctions
    • jobs
    • utils
  3. Complex with class pattern
    • com/acme/purpose/jira/validator

Or some combination or in-between.

Like Yogesh Mude likes this

This is almost exactly what I do.  I moved to scripts on disk very early on so I could store them in source control (that was before we had Bitbucket, but that's where I store them now)

I sometimes use a fourth (complex) naming convention which includes an indicator of the purpose of the script and/or the project it was written for (along with a set of global scripts)

Like Yogesh Mude likes this

Thank you @Peter-Dave Sheehan and @Nic Brough _Adaptavist_  for your suggestions and sharing the experience.

@Peter-Dave Sheehan yes, we are also thinking the same to put all the scripts to the server, and then using bitbucket and bamboo automation the respective scripts will be added/updated automatically. 


Log in or Sign up to comment
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...

188 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