Created
March 19, 2013 11:34
-
-
Save jamieechlin/5195423 to your computer and use it in GitHub Desktop.
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
def restParams = [ | |
className: "com.onresolve.jira.groovy.canned.admin.CopyProject", | |
args: [ | |
FIELD_SOURCE_PROJECT: SCRUM_TEMPLATE_PKEY, | |
FIELD_TARGET_PROJECT: projectKey, | |
FIELD_TARGET_PROJECT_NAME: projectName, | |
FIELD_COPY_VERSIONS: true, | |
FIELD_COPY_COMPONENTS: true, | |
FIELD_COPY_ISSUES: true, | |
FIELD_COPY_GREENHOPPER: true, | |
FIELD_COPY_DASH_AND_FILTERS: true, | |
] as JSON, | |
] | |
def http = new HTTPBuilder(baseUrl) | |
http.client.addRequestInterceptor(new HttpRequestInterceptor() { | |
void process(HttpRequest httpRequest, HttpContext httpContext) throws HttpException, IOException { | |
httpRequest.addHeader('Authorization', 'Basic ' + "${getAdmUserName()}:${getAdmPassword()}".toString().bytes.encodeBase64().toString()) | |
} | |
}) | |
// todo: assumption of context /jira | |
http.request(Method.POST, ContentType.TEXT) {req -> | |
uri.path = "/jira/rest/builtinscripts/latest/execute" | |
body = encodeMapAsUrl(restParams) | |
headers.Accept = 'application/json' | |
response.success = {resp, reader -> | |
log.debug("Succeeded") | |
log.debug(resp.statusLine) | |
} | |
response.failure = {resp, reader -> | |
log.debug("failed") | |
def text = reader.text | |
def errorCollection = new JsonSlurper().parseText(text as String) as Map | |
log.debug "errors:" + errorCollection.get("errors") | |
throw new Exception(errorCollection.get("errors").toString()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment