Created
January 3, 2014 16:19
-
-
Save jamieechlin/8240692 to your computer and use it in GitHub Desktop.
Post-function to copy a project
This file contains 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) : 'SOURCEKEY', | |
(CopyProject.FIELD_TARGET_PROJECT) : 'TARGETKEY', | |
(CopyProject.FIELD_TARGET_PROJECT_NAME) : "Target Name", | |
(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 = 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