We are planning to use Jira Software to track projects and tasks for a certain team. This team wont be doing code releases so don't need to track versions.
However they want to always set the fix versions field to the same value so can use the backlog board and version view option to see all items for their team.
---
How can a post-function script be used to always set the value of the fix versions field to be a default value. For example say always want version field to be ABC.
I tried creating a post-function with the script here
but I get a runtime error on the line this line due to null pointer (versionn = null)
issue.setFixVersions(Arrays.asList(versionn))
Thanks Alexey for your help. This is now working.
verssionn came back as null.
I figured out problem with script thanks to your help and looking values of the fields in console messages.
In line 9 of script above it had "WCE Security" but the actual Fix Version defined in Jira is "WCE Security Team". Once I changed line 9 to look for the right value the script now works to automatically sets the Fix Version in all new issues created.
It should be like this:
def version = ComponentAccessor.getVersionManager().getVersion(issue.getProjectId, "ABC");
issue.setFixVersions(Arrays.asList(version))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks - I modified the script with line above and getting a run time error.
Any advise would be greatly appreciated.
In Jira project there is one version setup with value of WCE Security
Post-function script on Create transiton is:
1 // Script to set value of Version for WCE Security Project issues
2 import com.atlassian.jira.project.version.Version
3 import com.atlassian.jira.project.version.VersionManager
4 import com.atlassian.jira.issue.fields.CustomField
5 import com.atlassian.jira.component.ComponentAccessor
6 import com.atlassian.jira.project.Project
7 VersionManager versionManager = ComponentAccessor.versionManager
8
9 String valueOfversion = "WCE Security"
10 Version versionn = versionManager.getVersion(issue.getProjectId(), valueOfversion)
11 issue.setFixVersions(Arrays.asList(versionn))
12 def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
13 log.warn ("+++ Issue " + issue + " valueOfversion = " + valueOfversion + " versionn = " + versionn)
14 ComponentAccessor.getIssueManager().updateIssue(user, issue, com.atlassian.jira.event.type.EventDispatchOption.DO_NOT_DISPATCH, false)
And it gives this error message.... line 11 fails, with null value for versionn I believe:
2018-05-16 16:21:00,872 https-jsse-nio-9445-exec-4 ERROR (my email) 980x29159x1 ckzv38 (IP) secure/QuickCreateIssue.jspa [c.o.s.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: null, actionId: 1, file: <inline script> java.lang.NullPointerException at Script1.run(Script1.groovy:11)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you log the variable versionn before line 11?
log.error("versionn: " + versionn)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tony Mackin It is very good to hear that it worked for you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.