Handle Jira ticket redirects - as a result of a jira ticket being moved to another project

This commit is contained in:
Dan Hawkins 2019-07-07 12:15:53 +01:00
commit 8ce4442dd6

View file

@ -197,8 +197,8 @@ def extractmerges(String line) {
def jiraticketexists(String jiraticket) {
def String URI = "${JIRA_URI}/browse/${jiraticket}"
def String URIforsummary = "${URI}?fields=summary"
def get = new URL(URIforsummary).openConnection();
def String RestfulURI = "${JIRA_URI}/rest/api/latest/issue/${jiraticket}?fields=summary"
def get = new URL(RestfulURI).openConnection();
get.setRequestProperty( 'X-AUSERNAME', "${JIRA_USERNAME}" )
get.setRequestProperty( 'Authorization', "Basic ${JIRA_ENCODED_PASSWORD}" )
get.setRequestProperty( 'User-Agent', 'groovy-2.4.4' )
@ -210,7 +210,6 @@ def jiraticketexists(String jiraticket) {
return [false, '', jiraticket]
} else {
def jsonresponse = new JsonSlurper().parseText(get.inputStream.getText('UTF-8'))
echo "Response: ${jsonresponse}"
redirectedjiraticket = jsonresponse['key']
}
return [true, URI, redirectedjiraticket]