Created
October 28, 2013 14:56
-
-
Save jechlin/7198215 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package examples | |
import com.atlassian.jira.component.ComponentAccessor | |
import com.onresolve.jira.groovy.canned.admin.CopyProject | |
import org.apache.log4j.Logger | |
def log = Logger.getLogger("com.onresolve.jira.groovy.MyScript") | |
Thread executorThread = new Thread(new Runnable() { | |
void run() { | |
def copyProject = new CopyProject() | |
def inputs = [ | |
(CopyProject.FIELD_SOURCE_PROJECT) : 'PRO', | |
(CopyProject.FIELD_TARGET_PROJECT) : 'AAA', | |
(CopyProject.FIELD_TARGET_PROJECT_NAME) : "Copied Project", | |
(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, | |
] | |
def errorCollection = copyProject.doValidate(inputs, false) | |
if(errorCollection.hasAnyErrors()) { | |
log.warn("Couldn't create project: $errorCollection") | |
} | |
else { | |
def util = ComponentAccessor.getUserUtil() | |
def adminsGroup = util.getGroupObject("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() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment