I'm using a script available on BitBucket.
I need to add to this script the following:
I have project A with Workflow A, and an issue A
Running issue A, at certain point of WF A, i need to create a new project (B) with diferent WF (B)
The new project B, will have by default an Epic (with the same issue.summary of issue A).
I have already automated the creation of project B (based on a template project with no issues).
Allong this automation, i need to create the project B, and an epic B linked to Issue A
and thats it. no more links from that point on.
Can anyone help.
Tks
//Based on this example https://gist.github.com/jamieechlin/8240692 /* There is a problem with this script in scriptrunner versions around 5.5 onwards as the CopyProject class was changed. It clones the project but does not clone the issues I will update when I have found the solution */ import com.atlassian.jira.component.ComponentAccessor import com.onresolve.scriptrunner.canned.jira.admin.CopyProject import org.apache.log4j.Logger import org.apache.log4j.Level def log = Logger.getLogger(getClass()) log.setLevel(Level.DEBUG) def customFieldManager = ComponentAccessor.getCustomFieldManager() def projectManager = ComponentAccessor.getProjectManager() //These fields will need to be created as single line text fields so users can provide the new project key and project name def destProjetKey = customFieldManager.getCustomFieldObjectsByName("New Project KEY")[0] log.debug("New Project KEY: " + issue.getCustomFieldValue(destProjetKey)) def destProjectName = customFieldManager.getCustomFieldObjectsByName("New Project Name")[0] log.debug("New Project Name: " + issue.getCustomFieldValue(destProjectName)) //change this to your template source project def srcProjectKey = 'SSPA' log.debug("Source Project Name: " + srcProjectKey) def getSrcProjectObject = projectManager.getProjectByCurrentKey(srcProjectKey) //Use getSrcProjectObject to check the source project exists def targetKey = issue.getCustomFieldValue(destProjetKey) def targetProjectName = issue.getCustomFieldValue(destProjectName) if(getSrcProjectObject && targetKey && targetProjectName) { Thread executorThread = new Thread(new Runnable() { void run() { def copyProject = new CopyProject() def inputs = [ (CopyProject.FIELD_SOURCE_PROJECT) : srcProjectKey, (CopyProject.FIELD_TARGET_PROJECT) : targetKey, (CopyProject.FIELD_TARGET_PROJECT_NAME) : targetProjectName, (CopyProject.FIELD_COPY_VERSIONS) : true, (CopyProject.FIELD_COPY_COMPONENTS) : true, (CopyProject.FIELD_COPY_ISSUES) : true, (CopyProject.FIELD_COPY_DASH_AND_FILTERS): false, //(CopyProject.FIELD_ORDER_BY) : "Rank", <-- no longer a valid option so I am commenting this out ] 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 ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(util.getUserByName(admins.first().name)) copyProject.doScript(inputs) } } }) executorThread.start() }else{ log.error("Cannot Clone Project as source Project, target key or target project names were Not found or Not specified") }
Hi Antonio
You are currently using that script to copy all issues from the source project.
(CopyProject.FIELD_COPY_ISSUES) : true,
For Point 1:
For Point 2:
Regards
Matthew
Hi Mattew,
bit messy my description. i try to simplify.
I have project A with Workflow A, and an issue A
Running issue A, at certain point of WF A, i need to create a new project (B) with diferent WF (B)
The new project B, will have by default an Epic (with the same issue.summary of issue A).
I have already automated the creation of project B (based on a template project with no issues).
Allong this automation, i need to create the project B, and an epic B linked to Issue A
and thats it. no more links from that point on.
hope this is clear than the previous description.
cheers
Antonio
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.