Skip to content

Commit 0dc8245

Browse files
committed
Trying to make the match a String
1 parent df68582 commit 0dc8245

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Jenkinsfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,17 +620,21 @@ def resolveBranchName(String featureBranchPRMinusNo, String orgName, String repo
620620
def branchNoMatcher = featureBranchPRMinusNo =~ /PR-(.*)/
621621
assert branchNoMatcher.find()
622622

623-
String prNo = branchNoMatcher[0][1]
623+
String prNo = branchNoMatcher.group(1)
624624
log("i", "PR number" + prNo)
625625

626626
// curl the repo based on the feature branch no to get the branch information
627627
/// Note: only works for public repos! Otherwise credentials needs to be passed
628-
def curlUrl = "set +x && curl -s https://api.github.com/repos/" + orgName + "/" + repoName + "/pulls/" + prNo
629-
String response = sh(script: curlUrl, returnStdout: true)
628+
String response = curlByPR(prNo, orgName, repoName)
630629
log("i", "API response:" + response)
631630
def jsonResponse = readJSON text: response
632631
def branchName = jsonResponse.head.ref
633632

634633
return branchName
634+
}
635635

636+
def curlByPR(String prId, String orgName, String repoName) {
637+
def curlUrl = "set +x && curl -s https://api.github.com/repos/" + orgName + "/" + repoName + "/pulls/" + prId
638+
String jsonResponseString = sh(script: curlUrl, returnStdout: true)
639+
return jsonResponseString
636640
}

0 commit comments

Comments
 (0)