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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

groovy CreateVersion and assignments are effective after reboot

When adding groovy script to my post functions I got the problem that versions were created and visible but not usable by creating a issues. This is only possible after Jira reboot. The same problem occur when I change the assigned person, some value sticks or something (which is solved after reindex).

How can I solve this problem? The createVersion is a real problem.....

3 answers

1 accepted

As Rob said in his comment, we provided him with the following workaround through our support portal. If anyone else is having issues, refer to this piece of code, but do let us know.

import com.atlassian.event.api.EventPublisher
import com.atlassian.jira.event.ClearCacheEvent

ComponentAccessor.getComponent(EventPublisher).publish(ClearCacheEvent.INSTANCE)

 Cheers!

DYelamos

It should work indeed, but after my update to jira 7.6.2 it looks if something is wrong with the indexer....

Suggestions?

I am not sure, why you have such behaviour. I think you should check log files

Here my log files result. 

at Script4.run(Script4.groovy:10)
java.lang.NullPointerException: Cannot invoke method getAt() on null object
Script field failed on issue: CV-241, field: Version
2018-03-12 08:03:33,466 http-nio-8080-exec-11 ERROR ROBS 483x6528x1 13y9gab 172.16.100.94,127.0.0.1 /secure/CommentAssignIssue.jspa [c.o.scriptrunner.customfield.GroovyCustomField] *************************************************************************************
2018-03-12 08:03:33,435 http-nio-8080-exec-11 WARN ROBS 483x6528x1 13y9gab 172.16.100.94,127.0.0.1 /secure/CommentAssignIssue.jspa [r.h.j.plugins.listener.HDEvListener] hd sendMail() no notification schema set for CV-241
2018-03-12 08:03:33,435 http-nio-8080-exec-11 WARN ROBS 483x6528x1 13y9gab 172.16.100.94,127.0.0.1 /secure/CommentAssignIssue.jspa [r.h.j.plugins.listener.HDEvListener] hd sendMail() notidSchema CV-241 
2018-03-12 08:03:33,434 http-nio-8080-exec-11 WARN ROBS 483x6528x1 13y9gab 172.16.100.94,127.0.0.1 /secure/CommentAssignIssue.jspa [r.h.j.plugins.listener.HDEvListener] hd sendEmail() was called with event issue CV-241 test_MECH_1.2.3-45_5 event type 5
2018-03-12 08:03:33,433 http-nio-8080-exec-11 WARN ROBS 483x6528x1 13y9gab 172.16.100.94,127.0.0.1 /secure/CommentAssignIssue.jspa [r.h.j.plugins.listener.HDEvListener] workflowEvent() was called with event issue CV-241 event type 5
at Script4.run(Script4.groovy:10)
java.lang.NullPointerException: Cannot invoke method getAt() on null object
Script field failed on issue: CV-241, field: Version
2018-03-12 08:02:50,842 http-nio-8080-exec-16 ERROR ROBS 482x6449x1 13y9gab 172.16.100.94,127.0.0.1 /secure/QuickCreateIssue.jspa [c.o.scriptrunner.customfield.GroovyCustomField] *************************************************************************************
at Script42.run(Script42.groovy:83)
at com.atlassian.jira.issue.index.IssueIndexManager$reIndex.call(Unknown Source)
at com.sun.proxy.$Proxy12.reIndex(Unknown Source)
at com.atlassian.jira.config.component.SwitchingInvocationHandler.invoke(SwitchingInvocationHandler.java:22)
at com.atlassian.jira.issue.index.DefaultIndexManager.reIndex(DefaultIndexManager.java:473)
at com.atlassian.jira.issue.index.DefaultIndexManager.reIndex(DefaultIndexManager.java:489)
at com.atlassian.jira.issue.index.DefaultIndexManager.reIndexIssueObjects(DefaultIndexManager.java:468)
at com.atlassian.jira.issue.index.DefaultIndexManager.reIndexIssues(DefaultIndexManager.java:571)
at com.atlassian.jira.issue.index.DefaultIssueIndexer.reindexIssues(DefaultIssueIndexer.java:165)
at com.atlassian.jira.issue.index.DefaultIssueIndexer.perform(DefaultIssueIndexer.java:285)
at com.atlassian.jira.issue.util.IssueObjectIssuesIterable.foreach(IssueObjectIssuesIterable.java:24)
at com.atlassian.jira.util.collect.CollectionUtil.foreach(CollectionUtil.java:52)
at com.atlassian.jira.util.collect.CollectionUtil.foreach(CollectionUtil.java:39)
at com.atlassian.jira.issue.index.DefaultIssueIndexer.lambda$perform$3(DefaultIssueIndexer.java:309)
at com.atlassian.jira.index.SimpleIndexingStrategy.get(SimpleIndexingStrategy.java:5)
at com.atlassian.jira.index.SimpleIndexingStrategy.get(SimpleIndexingStrategy.java:7)
at com.atlassian.jira.issue.index.DefaultIssueIndexer.lambda$null$2(DefaultIssueIndexer.java:311)
at com.atlassian.jira.issue.index.DefaultIssueIndexer.lambda$reindexIssues$1(DefaultIssueIndexer.java:169)
at com.atlassian.jira.issue.index.DefaultIssueIndexer$DefaultDocumentCreationStrategy.get(DefaultIssueIndexer.java:565)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory.apply(DefaultIssueDocumentFactory.java:30)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory.apply(DefaultIssueDocumentFactory.java:50)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory$Builder.addAll(DefaultIssueDocumentFactory.java:75)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory$Builder.add(DefaultIssueDocumentFactory.java:84)
at com.atlassian.jira.issue.index.indexers.impl.AbstractCustomFieldIndexer.addIndex(AbstractCustomFieldIndexer.java:40)
at com.atlassian.jira.issue.index.indexers.impl.SortableTextCustomFieldIndexer.addDocumentFieldsSearchable(SortableTextCustomFieldIndexer.java:30)
at com.atlassian.jira.issue.index.indexers.impl.SortableTextCustomFieldIndexer.addDocumentFields(SortableTextCustomFieldIndexer.java:39)
at com.atlassian.jira.issue.fields.ImmutableCustomField.getValue(ImmutableCustomField.java:350)
at com.onresolve.scriptrunner.customfield.GroovyCustomField.getValueFromIssue(GroovyCustomField.groovy:285)
at com.onresolve.scriptrunner.runner.ScriptRunner$runStringAsScript$7.call(Unknown Source)
at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runStringAsScript(ScriptRunnerImpl.groovy:143)
at com.onresolve.scriptrunner.runner.ScriptRunner$runScriptAndGetContext$8.callCurrent(Unknown Source)
at com.onresolve.scriptrunner.runner.ScriptRunner$runScriptAndGetContext$8.callCurrent(Unknown Source)
at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runScriptAndGetContext(ScriptRunnerImpl.groovy:154)
at Script4.run(Script4.groovy:10)
java.lang.NullPointerException: Cannot invoke method getAt() on null object
Script field failed on issue: CV-241, field: Version
2018-03-12 08:02:50,805 http-nio-8080-exec-16 ERROR ROBS 482x6449x1 13y9gab 172.16.100.94,127.0.0.1 /secure/QuickCreateIssue.jspa 

There is a problem with a listener. You should correct the Null Pointer Exception. As far as I understand your version is created correctly, is not it? And you can choose later manually for another field? Try to just to create a version with your script and see the result. Then you should corrent your Null Pointer Exception.

Hello Alexey,

I fixed the exception, but this has nothing to do with my problem. This still occurs:

 

afbeelding.png

Do I understand correctly, that you have a post function, where you create a version? then you open another ticket and try to choose the created version and you have the error?

That is a strange behaviour. I do not think there are any problems with indexes. Because indexes store issue data. When you created a version it is not an issue data. It will become issue data only when you set this version for an issue.

By the way I tested your script on Jira 7.7.0 and it worked fine

Sorry for the delay but I had to install Jira 7.8.0 which took some time. But the problems is NOT solved. I still got the " version with id does not exist". This is really strange. Are there any configuration settings you know?

I do not know such options. It worked for me out of the box

Any suggestions who I can contact? I am really stuck at the moment.

Try to publish the same question again.

import com.atlassian.event.api.EventPublisher
import com.atlassian.jira.event.ClearCacheEvent

ComponentAccessor.getComponent(EventPublisher).publish(ClearCacheEvent.INSTANCE)

An clear jira cache does do the trick. This is an acceptable workaround.

0 votes

Could you provide your script?

Hello Alexey

Off course:

// get project number
def project = issue.getProjectObject().getId();

// Get issue transientVars
Issue transIssue = (Issue) transientVars.get("issue");

// Get stored version information => stored in the validation step!
def relVersion = ComponentAccessor.getCustomFieldManager().getCustomFieldObjects(transIssue).find {it.name == 'release_version'};
   
// New version
newVersion = issue.getCustomFieldValue(relVersion);

// Add new version (released today)
ComponentAccessor.getVersionManager().createVersion(newVersion, null, new Date(), "", project, null, true);

The version is created, but it can not be used. Can I re-index projects? or versions? Because I think that is the problem.

I just tried your script. It works fine for me. Your script creates a released version and then I can choose the version for an issue without additional actions.

It should work indeed, but after my update to jira 7.6.2 it looks if something is wrong with the indexer....

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

65 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you