I am currently playing with Script Runner and post-functions.
I would like to know how to improve my debugging workflow.
So far, the best way I have found is
The problem with this workflow is that not everything that the context of a post-function is different from the context of a Scripted Field. As a consequence of this, sometimes when I transfer my the script from Scripted Field to post-function I get unexpected errors.
Thereafter, to correct errors in the post-function I found that the following workflow is required
I find this workflow quite time consuming, so I wonder whether a faster debugging workflow for post-function exists.
You could add logging statements like:
to see the value of variables and the general execution of the script. However this is quite time consuming for more complex scripts.
If you really want to debug a post-function properly its probably best to do it in a test/staging instance of JIRA, adding the post-function as as a script file. Then follow the instructions here for setting up a development environment in an IDE to allow debugging of the script.
Note that the instructions at that link are not fully up to date but it should get you going with the general approach to take to debugging your script.
If you are using script console, you can use:
import com.onresolve.scriptrunner.runner.customisers.ContextBaseScript import groovy.transform.BaseScript @BaseScript ContextBaseScript baseScript def issue = getIssueOrDefault("ABC-1")
If it's not running in a workflow function, it will use ABC-1, otherwise whatever the issue is. So you don't need to remember to comment it again.
I usually use Script console. And I add an issue variable like this:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject("zxcv-1")
After this I comment this line before place it to postfunction.
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs