Last active
August 10, 2019 03:40
-
-
Save matts-mpg/ddbdcb23f52f96178cfa614423d486ca to your computer and use it in GitHub Desktop.
Fully working from the Confluence Scriptrunner console this will create a new Epic in PROJECT.
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
| import com.atlassian.applinks.api.ApplicationLinkService | |
| import com.atlassian.applinks.api.application.jira.JiraApplicationType | |
| import com.atlassian.sal.api.component.ComponentLocator | |
| import com.atlassian.sal.api.net.Response | |
| import com.atlassian.sal.api.net.ResponseException | |
| import com.atlassian.sal.api.net.ResponseHandler | |
| import groovy.json.JsonBuilder | |
| import static com.atlassian.sal.api.net.Request.MethodType.POST | |
| def appLinkService = ComponentLocator.getComponent(ApplicationLinkService) | |
| def appLink = appLinkService.getPrimaryApplicationLink(JiraApplicationType) | |
| def applicationLinkRequestFactory = appLink.createAuthenticatedRequestFactory() | |
| String body = new JsonBuilder([ | |
| fields: [ | |
| project : [key: "PROJECT"], | |
| "customfield_10002" : "more", | |
| summary : "lists are hard", | |
| description : "ononononon", | |
| issuetype : [id: 10000L] | |
| ] | |
| ]).toString() | |
| def request = applicationLinkRequestFactory.createRequest(POST, "/rest/api/2/issue") | |
| .addHeader("Content-Type", "application/json") | |
| .setEntity(body) | |
| def jsonSlurper = new JsonSlurper() | |
| def createdIssue = jsonSlurper.parseText(request.execute()) | |
| return createdIssue.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment