Skip to content

Commit c821337

Browse files
committed
Parse to JSON before and access properties there
1 parent d42a3f4 commit c821337

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

Jenkinsfile

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -627,18 +627,20 @@ def resolveBranchName(String featureBranchPRMinusNo, String orgName, String repo
627627
/// Note: only works for public repos! Otherwise credentials needs to be passed
628628
def curlUrl = "set +x && curl -s https://api.github.com/repos/" + orgName + "/" + repoName + "/pulls/" + prNo
629629
String response = sh(script: curlUrl, returnStdout: true)
630-
def matcher = response =~ /\"label\":\s\"(.+)\"/
631-
632-
assert matcher.find()
633-
634-
// get split the label to account for PRs from forks
635-
def split = matcher[0][1] =~ /(.*):(.*)/
636-
637-
assert matcher.find()
638-
639-
def username = split[0][1]
640-
def branch = split[0][2]
641-
642-
return branch
630+
def jsonResponse = readJSON text: response
631+
def branchName = jsonResponse.head.ref
632+
// def matcher = response =~ /\"label\":\s\"(.+)\"/
633+
//
634+
// assert matcher.find()
635+
//
636+
// // get split the label to account for PRs from forks
637+
// def split = matcher[0][1] =~ /(.*):(.*)/
638+
//
639+
// assert matcher.find()
640+
//
641+
// def username = split[0][1]
642+
// def branch = split[0][2]
643+
644+
return branchName
643645

644646
}

0 commit comments

Comments
 (0)