Guest User

Untitled

a guest
Feb 10th, 2022
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. task moveJiraTasks {
  2. doLast {
  3. //task numbers, separated by comma: 1,2,3...
  4. def taskNumbers = project.properties['items'].split(',').toUnique()
  5. println "task numbers: $taskNumbers"
  6. //should be base64 from email:token
  7. def jiraToken = project.properties['jira_token']
  8. def column = project.properties['column'].toString()
  9. def transactionId = -1
  10. // constants from Jira. Can get from request:
  11. // GET https://domain.atlassian.net/rest/api/3/issue/TASK-number/transitions
  12. // issue number can be random from the board
  13. if(column.equalsIgnoreCase("Review")) {
  14. transactionId = 10
  15. } else if(column.equalsIgnoreCase("QA")) {
  16. transactionId = 11
  17. }
  18. for(taskNumber in taskNumbers) {
  19. def body = "{ \"transition\": { \"id\": \"$transactionId\" } }"
  20. def req = new URL("https://domain.atlassian.net/rest/api/3/issue/TASK-$taskNumber/transitions").openConnection()
  21. req.setRequestMethod("POST")
  22. req.setRequestProperty("Content-Type", "application/json; charset=UTF-8")
  23. req.setRequestProperty("Authorization", "Basic $jiraToken")
  24. req.setDoOutput(true)
  25. req.getOutputStream().write(body.getBytes("UTF-8"))
  26. println "Status code: ${req.getResponseCode()} for task $taskNumber"
  27. }
  28. }
  29. }
Add Comment
Please, Sign In to add comment