Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- task moveJiraTasks {
- doLast {
- //task numbers, separated by comma: 1,2,3...
- def taskNumbers = project.properties['items'].split(',').toUnique()
- println "task numbers: $taskNumbers"
- //should be base64 from email:token
- def jiraToken = project.properties['jira_token']
- def column = project.properties['column'].toString()
- def transactionId = -1
- // constants from Jira. Can get from request:
- // GET https://domain.atlassian.net/rest/api/3/issue/TASK-number/transitions
- // issue number can be random from the board
- if(column.equalsIgnoreCase("Review")) {
- transactionId = 10
- } else if(column.equalsIgnoreCase("QA")) {
- transactionId = 11
- }
- for(taskNumber in taskNumbers) {
- def body = "{ \"transition\": { \"id\": \"$transactionId\" } }"
- def req = new URL("https://domain.atlassian.net/rest/api/3/issue/TASK-$taskNumber/transitions").openConnection()
- req.setRequestMethod("POST")
- req.setRequestProperty("Content-Type", "application/json; charset=UTF-8")
- req.setRequestProperty("Authorization", "Basic $jiraToken")
- req.setDoOutput(true)
- req.getOutputStream().write(body.getBytes("UTF-8"))
- println "Status code: ${req.getResponseCode()} for task $taskNumber"
- }
- }
- }
Add Comment
Please, Sign In to add comment