Hi,
I have just installed the cloud plugin for script runner and trying my first script.
I have the following code and error:
import com.atlassian.jira.component.ComponentAccessor
def versionManager = ComponentAccessor.getVersionManager()
def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectObjByKey(issue.projectObject.key)
def versions = versionManager.getVersions(project)
def versionNoCodeChange = versions.find( it.name.equals('no-code-change') )
issue.setFixVersions(Arrays.asList(versionNoCodeChange))
2018-06-26 09:13:29.540 ERROR - startup failed: Script1.groovy: 1: unable to resolve class com.atlassian.jira.component.ComponentAccessor @ line 1, column 1. import com.atlassian.jira.component.ComponentAccessor ^ 1 error 2018-06-26 09:13:29.579 ERROR - Class: com.adaptavist.sr.cloud.workflow.UpdateIssue, Config: [className:com.adaptavist.sr.cloud.workflow.UpdateIssue, uuid:cfe72c36-d292-4a17-99a5-ef39821aceb2, description:Set fix-version to no-code-change, enabled:true, executionUser:INITIATING_USER, additionalCode:import com.atlassian.jira.component.ComponentAccessor def versionManager = ComponentAccessor.getVersionManager() def projectManager = ComponentAccessor.getProjectManager() def project = projectManager.getProjectObjByKey(issue.projectObject.key) def versions = versionManager.getVersions(project) def versionNoCodeChange = versions.find( it.name.equals('no-code-change') ) issue.setFixVersions(Arrays.asList(versionNoCodeChange)), userKey:mitch.kent]
This is, as I say, from the post-function screen.
I've searched and there are many posts around this functionality, but all seem to use the ComponentAccessor which I can't get, so am stuck on first hurdle.
Many thanks,
Mitch.
Hi Mitch,
I can confirm that your code is from the ScriptRunner for Jira Server plugin and the Jira Cloud version.
The reason for that is that the cloud version can only make changes to Jira via the Atlassian Rest API's as cloud does not have a Java API like the server version does.
This is described in more detail in the documentation page located here.
In order to set the version field for an issue inside of a post function on a cloud instance then you will need to use the Run Script post function which is described in the documentation here.
I have created some example code which shows how you can get the set the fix versions on an issue during a post function which can be viewed here. This code will show you how to set versions and can be used to create the script that you require.
If this answer has solved your issue can you please accept it in order to mark this answer as correct for users who are searching for a similar issue.
Regards,
Kristian
Hi Kristian,
Thanks for your response.
The reason for that is that the cloud version can only make changes to Jira via the Atlassian Rest API's as cloud does not have a Java API like the server version does.
I realise this is the case, but I wrongly presumed the script runner plugin wrapped these things up in its own library - having looked into it more since I realise how wrong this is :)
This does mean that everything will become vastly more complex after this single example, for any future stuff I would like to work on. As such, there is no point in me continuing with the plugin, and have disabled it.
I appreciate your answer, but I wont be able to use or test it, so I can't mark it as correct.
Regards,
Mitch.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
You are writing a script for Scriptrunner for Jira Server Version. You can not use same scripts for Cloud and Server version. Cloud is built upon Rest calls. Kindly have a look at the documentation for ScriptRunner Cloud:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Alexey.
This looks massively more complicated and effort, though I can appreciate the reasons now I've read through the page.
I think I'll just delete the plugin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.