Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Best practice for managing scripts

Yogesh Mude
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 24, 2020

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

Comment

Log in or Sign up to comment
Peter-Dave Sheehan
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 24, 2020

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
Nic Brough -Adaptavist-
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 25, 2020

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
Yogesh Mude
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 25, 2020

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. 

TAGS
AUG Leaders

Atlassian Community Events