Script runner validator not working

BrianB March 3, 2016

I am trying to force user to link an issue before they can transition.

 

Here is the validator I added

 Script workflow function : The following fields will require to have their values changed: Linked Issues

It allows me to proceed even though there are no linked issues in the JIRA

 

Using JIRA 6.1.6  and groovy 2.1.16.

 

I have also tried "Field has been modified Validator" from JIRA Misc Workflow  plugin, and I experience the same result

 

4 answers

1 accepted

0 votes
Answer accepted
BrianB March 9, 2016

I've added my own custom Groovy script using ActionContext.getRequest and the functionality meets my requirements. Thanks

Jamie Echlin _ScriptRunner - The Adaptavist Group_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
March 9, 2016
BrianB March 10, 2016

Yes this works. Thanks Jamie. But I need to point out that this canned script does not work:

 

 Script workflow function : The following fields will require to have their values changed: Linked Issues

Maybe it's a moot point because this is an older version of scriptrunner

 

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 7, 2016

Hi Brian,

I have attached an example as shown in the screenshots in the document here which shows how you can add a Simple Scripted Validator to a transition to say the transition can only occur when an issue has one of more linked issues. In the example attached I am blocking the To-Do to In Progress transition when no linked issue is on the issue being transitioned.

The code used for the scripted validator is:

// Issue must have at least one Linked Issue attached to it
issueLinkManager.getOutwardLinks(issue.getId()).size() >= 1

If you wish to specify a specific issue type then you can do this using code similar to below for the scripted validator.

// Issue must have a linked issue of the type Duplicate
issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Duplicate')

I hope this helps.

Thanks

Kristian

 

BrianB March 8, 2016

Thanks Kristian, this will work only if an issue is linked previously.  I'd like to force linkage during the transition and have added a transition screen with Linked Issues on it. Unfortunately, since the issue is not linked in the database, it will not recognize the linked issue added in the screen.

 

I'm guessing there is a bug in my original way to do this?
Script workflow function : The following fields will require to have their values changed: Linked Issues

 

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2016

Have you placed yout post function so that it is the last post function in the list and appears below the Re-index an issue to keep indexes in sync with the database post function?

BrianB March 8, 2016

This isn't a post-function. It is a validator

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2016

Are you using the simple scripted validator provided by the Script Runner plugin as the two code snippets above are the will work for ensuring a linked pressent before the transition is allowed.

Also can you please share some screenshots of what you have configured and the extracts of the atlassian-jira.log file from when the transition is executed so we can try to help you further.

Kristian

BrianB March 8, 2016

Approval Workflow Screen.pngLinking Issue.pngError Received.pngWorkflow Validator.pngSimple Script Screen.png

2016-03-08 11:01:29,922 http-bio-443-exec-3 ERROR cbashyb 661x721x1 1o3blpu 10.46.58.156

/secure/CommentAssignIssue.jspa [atlassian.jira.workflow.OSWorkflowManager] Caught exception while attempting to

perform action 771 from workflow 450381 on issue 'EDD-25' [InvalidInputException: [Error map: [{}]] [Error list: [[You must link a Project JIRA Issue in order to

proceed]]]  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)  at java.lang.reflect.Constructor.newInstance(Unknown Source)  at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)  at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71)  at org.codehaus.groovy.runtime.callsite.ConstructorSite.callConstructor(ConstructorSite.java:42)  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)  at com.onresolve.jira.groovy.canned.workflow.validators.SimpleScriptedValidator.doScript

(SimpleScriptedValidator.groovy:66)  at com.onresolve.jira.groovy.canned.CannedScript$doScript.call(Unknown Source)  at com.onresolve.jira.groovy.CannedScriptRunner.runCannedScript(CannedScriptRunner.groovy:63)  at com.onresolve.jira.groovy.GroovyRunner.run(GroovyRunner.java:52)  at com.onresolve.jira.groovy.GroovyValidator.validate(GroovyValidator.java:47)  at com.opensymphony.workflow.AbstractWorkflow.verifyInputs(AbstractWorkflow.java:1512)  at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1203)  at com.opensymphony.workflow.AbstractWorkflow.doAction(AbstractWorkflow.java:564)  at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowActionInsideTxn(OSWorkflowManager.java:954)  at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowAction(OSWorkflowManager.java:909)  at com.atlassian.jira.bc.issue.DefaultIssueService.transition(DefaultIssueService.java:450)  at com.atlassian.jira.web.action.issue.CommentAssignIssue.doExecute(CommentAssignIssue.java:192)  <+1>

(ActionSupport.java:165)  at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:87)  <+7>

(DefaultInterceptorChain.java:39) (NestedInterceptorChain.java:31) (ChainedInterceptor.java:16)

(DefaultInterceptorChain.java:35) (GenericDispatcher.java:225) (GenericDispatcher.java:154)

(JiraWebworkActionDispatcher.java:152)  at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)  <+14> (ApplicationFilterChain.java:305)

(ApplicationFilterChain.java:210) (ChainedFilterStepRunner.java:87) (ApplicationFilterChain.java:243)

(ApplicationFilterChain.java:210) (XContentTypeOptionsNoSniffFilter.java:22) (AbstractHttpFilter.java:31)

(ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (HeaderSanitisingFilter.java:44)

(ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (IteratingFilterChain.java:46)

(DelegatingPluginFilter.java:66)  at com.atlassian.jira.tzdetect.IncludeResourcesFilter.doFilter(IncludeResourcesFilter.java:39)  <+3>

(DelegatingPluginFilter.java:74) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:66)  at com.atlassian.jira.baseurl.IncludeResourcesFilter.doFilter(IncludeResourcesFilter.java:38)  <+8>

(AbstractHttpFilter.java:31) (DelegatingPluginFilter.java:74) (IteratingFilterChain.java:42)

(DelegatingPluginFilter.java:66) (ContextFilter.java:25) (DelegatingPluginFilter.java:74)

(IteratingFilterChain.java:42) (DelegatingPluginFilter.java:66)  at com.atlassian.mywork.client.filter.ServingRequestsFilter.doFilter(ServingRequestsFilter.java:37)  <+3>

(DelegatingPluginFilter.java:74) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:66)  at com.atlassian.prettyurls.filter.PrettyUrlsDispatcherFilter.doFilter

(PrettyUrlsDispatcherFilter.java:60)  <+3> (DelegatingPluginFilter.java:74) (IteratingFilterChain.java:42)

(DelegatingPluginFilter.java:66)  at com.atlassian.prettyurls.filter.PrettyUrlsSiteMeshFilter.doFilter(PrettyUrlsSiteMeshFilter.java:92) 

<+3> (DelegatingPluginFilter.java:74) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:66)  at com.atlassian.prettyurls.filter.PrettyUrlsMatcherFilter.doFilter(PrettyUrlsMatcherFilter.java:56)  <

+3> (DelegatingPluginFilter.java:74) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:66)  at com.atlassian.labs.botkiller.BotKillerFilter.doFilter(BotKillerFilter.java:36)  <+23>

(DelegatingPluginFilter.java:74) (IteratingFilterChain.java:42) (ServletFilterModuleContainerFilter.java:77)

(ServletFilterModuleContainerFilter.java:63) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210)

(AccessLogFilter.java:103) (AccessLogFilter.java:87) (ApplicationFilterChain.java:243)

(ApplicationFilterChain.java:210) (XsrfTokenAdditionRequestFilter.java:54) (ApplicationFilterChain.java:243)

(ApplicationFilterChain.java:210) (SiteMeshFilter.java:181) (SiteMeshFilter.java:85)

(SitemeshPageFilter.java:123) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210)

(ChainedFilterStepRunner.java:87) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210)

(IteratingFilterChain.java:46) (DelegatingPluginFilter.java:66)  at com.atlassian.prettyurls.filter.PrettyUrlsCombinedMatchDispatcherFilter.doFilter

(PrettyUrlsCombinedMatchDispatcherFilter.java:61)  <+22> (DelegatingPluginFilter.java:74)

(IteratingFilterChain.java:42) (ServletFilterModuleContainerFilter.java:77)

(ServletFilterModuleContainerFilter.java:63) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210)

(SecurityFilter.java:234) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210)

(TrustedApplicationsFilter.java:100) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210)

(BaseLoginFilter.java:169) (JiraLoginFilter.java:70) (ApplicationFilterChain.java:243)

(ApplicationFilterChain.java:210) (IteratingFilterChain.java:46) (DelegatingPluginFilter.java:66)

(OAuthFilter.java:55) (DelegatingPluginFilter.java:74) (IteratingFilterChain.java:42)

(DelegatingPluginFilter.java:66)  at com.atlassian.prettyurls.filter.PrettyUrlsCombinedMatchDispatcherFilter.doFilter

(PrettyUrlsCombinedMatchDispatcherFilter.java:61)  <+13> (DelegatingPluginFilter.java:74)

(IteratingFilterChain.java:42) (ServletFilterModuleContainerFilter.java:77)

(ServletFilterModuleContainerFilter.java:63) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210)

(ProfilingFilter.java:99) (JIRAProfilingFilter.java:19) (ApplicationFilterChain.java:243)

(ApplicationFilterChain.java:210) (AbstractJohnsonFilter.java:71) (ApplicationFilterChain.java:243)

(ApplicationFilterChain.java:210)  at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)  at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)  at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)  <+10>

(UrlRewriteFilter.java:394) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210)

(GzipFilter.java:80) (GzipFilter.java:51) (JiraGzipFilter.java:55) (ApplicationFilterChain.java:243)

(ApplicationFilterChain.java:210) (IteratingFilterChain.java:46) (DelegatingPluginFilter.java:66)  at com.atlassian.prettyurls.filter.PrettyUrlsCombinedMatchDispatcherFilter.doFilter

(PrettyUrlsCombinedMatchDispatcherFilter.java:61)  <+41> (DelegatingPluginFilter.java:74)

(IteratingFilterChain.java:42) (DelegatingPluginFilter.java:66) (JWDSendRedirectFilter.java:25)

(DelegatingPluginFilter.java:74) (IteratingFilterChain.java:42) (ServletFilterModuleContainerFilter.java:77)

(ServletFilterModuleContainerFilter.java:63) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210)

(ChainedFilterStepRunner.java:87) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210)

(AbstractCachingFilter.java:33) (AbstractHttpFilter.java:31) (ApplicationFilterChain.java:243)

(ApplicationFilterChain.java:210) (AbstractEncodingFilter.java:41) (AbstractHttpFilter.java:31)

(PathMatchingEncodingFilter.java:49) (AbstractHttpFilter.java:31) (ApplicationFilterChain.java:243)

(ApplicationFilterChain.java:210) (JiraStartupChecklistFilter.java:78) (ApplicationFilterChain.java:243)

(ApplicationFilterChain.java:210) (ChainedFilterStepRunner.java:87) (JiraFirstFilter.java:57)

(ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (StandardWrapperValve.java:225)

(StandardContextValve.java:123) (AuthenticatorBase.java:581) (StandardHostValve.java:168)

(ErrorReportValve.java:98) (StandardEngineValve.java:118) (AccessLogValve.java:927) (CoyoteAdapter.java:407)

(AbstractHttp11Processor.java:1001) (AbstractProtocol.java:585) (JIoEndpoint.java:310)  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  at java.lang.Thread.run(Unknown Source)

Attaching screen shots and error log. I still believe it is giving error, because I am trying to link the issue in the transition screen.

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2016

Can you please try removing the transition screen and test if the validator works as expected without the transition screen.

Thanks

Kristian

BrianB March 8, 2016

Yes it will work without the transition screen. But my requirement is to link during the transition.

0 votes
BrianB March 4, 2016

It can be any parent-child link.  The workflow is allowing the transition if I have no link at all

0 votes
Vasiliy Zverev
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.
March 3, 2016

Do you need that user make any link or a link of specified type, for example bloked by?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events