Push to git on saving Scriptrunner script

Dominic Lagger
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.
November 17, 2020

Hi all

We have a lot of Scriptrunner scripts.

I want a history for those scripts and thought of git. Is there any change to push the whole script to git when I save the script?

Is there an event I can fire or any listener for this? 

Thanks for any ideas.

Regards, Dominic

1 answer

0 votes
Tiffany Wortham
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.
January 7, 2021

So, there are a couple of different approaches that you could take with this one. Unfortunately, there aren't any ScriptRunner events associated with scripts or the saving/editing of them, so most of making this happen will probably have to be done outside of ScriptRunner.

1. If you're using the script editor for your scripts, you could use something to watch file system events and when changes occur to the scripts, a shell script is run which commits and pushes the updated files. I understand that this may not be ideal as you may not currently be using the script editor for all of your scripts, but it may be worthwhile to have users move those scripts which don't use the script editor.

2. You could have users PR their scripts into a branch on a repo which is a copy of your script root, and you could create a cron job that pulls the changes from the remote repo to the script root on the server every so often.

As you create your solution, it'll probably be helpful to refer to this section of the docs on script version control best practices (this is currently only in our docs for ScriptRunner for Jira but applies to ScriptRunner for Confluence as well): https://scriptrunner.adaptavist.com/latest/jira/script-version-control.html

Also, here's our documentation on script roots: https://scriptrunner.adaptavist.com/6.16.0/confluence/_script_roots.html

Dominic Lagger
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.
January 8, 2021

Hi @Tiffany Wortham 

Thank you for your answer. I appreciate it!

Both options aren't the perfect match for my wish. 

I wished, there was a "Save" Event for ScriptRunner scripts. With the save event, I would then create a REST-call to my existing git project and pull the new content of the script.

Regards, Dominic

Yoni Segal November 9, 2022

@Tiffany Wortham Has there been any update on this?
It seems quite strange to not be able to use version control to host the scripts.

 

@Dominic Lagger Were you able to find any better solutions?

Dominic Lagger
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.
November 13, 2022

Sadly, no

I copy the scripts to git once I think i'm finished :) 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.4.1
TAGS
AUG Leaders

Atlassian Community Events