Hi,
I trying prepare self service to creating JIRA projects. Now in JIRA working project clone, but just without issues - everythink looks good, but i last case i need copy Issues from source project. I trying a lot things with code like below :
package examples
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.canned.jira.admin.CopyProject
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.issue.Issue
//import com.onresolve.jira.groovy.user.FormField
import org.apache.log4j.Logger
import org.apache.log4j.Level
Logger.getLogger("com.onresolve").setLevel(Level.DEBUG)
def log = Logger.getLogger("com.onresolve.jira.groovy.MyCopyProjectScript")
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def destProjetKey = 'ASAP'
def srcProjectKey = 'SPP'
def destProjectName = 'ASAP'
log.debug("Source Project Name: " + srcProjectKey)
Thread executorThread = new Thread(new Runnable() {
void run() {
def copyProject = new CopyProject()
def inputs = [
(CopyProject.FIELD_SOURCE_PROJECT) : srcProjectKey,
(CopyProject.FIELD_TARGET_PROJECT) : destProjetKey,
(CopyProject.FIELD_TARGET_PROJECT_NAME) : destProjectName,
(CopyProject.FIELD_COPY_VERSIONS) : true,
(CopyProject.FIELD_COPY_COMPONENTS) : true,
(CopyProject.FIELD_COPY_ISSUES) : true,
//(CopyProject.FIELD_COPY_GREENHOPPER) : false,
(CopyProject.FIELD_COPY_DASH_AND_FILTERS) : false,
(CopyProject.FIELD_ORDER_BY) : "Rank",
]
def errorCollection = copyProject.doValidate(inputs, false)
if(errorCollection.hasAnyErrors()) {
log.warn("Couldn't create project: " + errorCollection)
}
else {
def util = ComponentAccessor.getUserUtil()
def adminsGroup = ComponentAccessor.getGroupManager().getGroup("jira-administrators")
assert adminsGroup // must have jira-administrators group defined
def admins = util.getAllUsersInGroups([adminsGroup])
assert admins // must have at least one admin
def executingAdmin = ComponentAccessor.getUserManager().getUserByName(admins.first().name)
log.debug("Executing Admin: " + executingAdmin.getName())
ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(executingAdmin)
copyProject.doScript(inputs)
}
}
})
executorThread.run()
and without result. Code working fine in "Run Script" from Add-ons level, but from transition leve Issues is not able to copy (with error NullPointerException. In atlassian-jira I receiving:
2019-01-21 11:36:23,529 ajp-nio-8009-exec-2 ERROR 696x12002x1 1kbyjsn /secure/WorkflowUIDispatcher.jspa [c.o.s.c.jira.utils.AbstractCloneIssue] Failed to create issue
com.atlassian.jira.exception.CreateException: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Expected one match for [Expr::id::=::15123] but found 0: []
and:
2019-01-21 11:36:23,544 ajp-nio-8009-exec-2 ERROR 696x12002x1 1kbyjsn /secure/WorkflowUIDispatcher.jspa [c.o.s.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: SS-105, actionId: 111, file: <inline script>
java.lang.NullPointerException
I tried:
- remove any validators
- every place in post function
- use 2 type of post funcions: JMWE groovy script and scriptu runner script
- allow everything for my user in permission scheme
- change executingadmin
but still everything working fine from Add-ons level, but not working from transition level.
JIRA 7.10.2
ScriptRunner 5.4.47
Anyone have any idea? I will be grateful for any advise.
In your description, you mentioned:-
Now I'd like my script to be able to detect changes produced on custom fields context, for instance if a custom field is assigned to/removed from a project or issuetype.
I didn't find information about which class has to be imported to get that event data, until now I've found only a way to detect when the cf is edited (by pressing the EDIT button), but not when its context is altered (by pressing the CONFIGURE button).
Unfortunately, this is not doable. Even if you configure it to a Generic Event, modifying the field context will not trigger any change.
Thank you and Kind regards,
Ram
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.