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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,552,107
Community Members
 
Community Events
184
Community Groups

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

0 votes
Answer accepted
Daniel Yelamos [Adaptavist]
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.
Mar 22, 2018

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?

Alexey Matveev
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.
Mar 11, 2018

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 

Alexey Matveev
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.
Mar 12, 2018

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

Alexey Matveev
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.
Mar 12, 2018

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?

Alexey Matveev
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.
Mar 12, 2018

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.

Alexey Matveev
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.
Mar 12, 2018

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?

Alexey Matveev
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.
Mar 20, 2018

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.

Alexey Matveev
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.
Mar 20, 2018

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
Alexey Matveev
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.
Mar 09, 2018

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.

Alexey Matveev
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.
Mar 11, 2018

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
AUG Leaders

Atlassian Community Events