Handle Jira ticket redirects - as a result of a jira ticket being moved to another project
This commit is contained in:
parent
aecd252a57
commit
877f022678
1 changed files with 12 additions and 8 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import groovy.json.JsonSlurper
|
||||
|
||||
markunstable = false
|
||||
unstablereason = ""
|
||||
|
||||
|
|
@ -203,10 +205,15 @@ def jiraticketexists(String jiraticket) {
|
|||
get.setRequestProperty( 'Accept', 'application/json' )
|
||||
def getRC = get.getResponseCode();
|
||||
|
||||
def String redirectedjiraticket = jiraticket
|
||||
if(!getRC.equals(200)) {
|
||||
return [false, '']
|
||||
return [false, '', jiraticket]
|
||||
} else {
|
||||
def jsonresponse = new JsonSlurper().parseText(get.inputStream.getText('UTF-8'))
|
||||
echo "Response: ${jsonresponse}"
|
||||
redirectedjiraticket = jsonresponse['key']
|
||||
}
|
||||
return [true, URI]
|
||||
return [true, URI, redirectedjiraticket]
|
||||
}
|
||||
|
||||
def extractjiraticketinfo(String line) {
|
||||
|
|
@ -225,8 +232,7 @@ def extractjiraticketinfo(String line) {
|
|||
def match1 = (line =~ pattern1)
|
||||
if (match1.find()) {
|
||||
jiraticket = match1.group(1)
|
||||
jiraticket = jiraticket.toUpperCase()
|
||||
(exists, URI) = jiraticketexists(jiraticket)
|
||||
(exists, URI, jiraticket) = jiraticketexists(jiraticket)
|
||||
if (exists) {
|
||||
def JiraTicketInfo j = new JiraTicketInfo()
|
||||
j.jiranumber = jiraticket
|
||||
|
|
@ -241,8 +247,7 @@ def extractjiraticketinfo(String line) {
|
|||
def match2 = (line =~ pattern2)
|
||||
if (match2.find()) {
|
||||
jiraticket = match2.group(1) + "-" + match2.group(2)
|
||||
jiraticket = jiraticket.toUpperCase()
|
||||
(exists, URI) = jiraticketexists(jiraticket)
|
||||
(exists, URI, jiraticket) = jiraticketexists(jiraticket)
|
||||
if (exists) {
|
||||
def JiraTicketInfo j = new JiraTicketInfo()
|
||||
j.jiranumber = jiraticket
|
||||
|
|
@ -257,8 +262,7 @@ def extractjiraticketinfo(String line) {
|
|||
def match3 = (line =~ pattern3)
|
||||
if (match3.find()) {
|
||||
jiraticket = match3.group(1) + "-" + match3.group(2)
|
||||
jiraticket = jiraticket.toUpperCase()
|
||||
(exists, URI) = jiraticketexists(jiraticket)
|
||||
(exists, URI, jiraticket) = jiraticketexists(jiraticket)
|
||||
if (exists) {
|
||||
def JiraTicketInfo j = new JiraTicketInfo()
|
||||
j.jiranumber = jiraticket
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue