-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Prudhvi Godithi <[email protected]>
- Loading branch information
1 parent
8776b89
commit 9fd97be
Showing
9 changed files
with
126 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
/** Library to close GitHub issue across opensearch-project repositories. | ||
@param Map args = [:] args A map of the following parameters | ||
@param args.message <required> - message retrieved from buildMessage() method. | ||
@param args.inputManifestPath <required> - Path to input manifest. | ||
*/ | ||
void call(Map args = [:]) { | ||
lib = library(identifier: 'jenkins@main', retriever: legacySCM(scm)) | ||
def passMessages = args.message | ||
List<String> passedComponents = [] | ||
else { | ||
for (message in passMessages.unique()) { | ||
java.util.regex.Matcher match = (message =~ /(?<=\bBuild successful\s).*/) | ||
String matched = match[0] | ||
println(matched.split(" ")[0].trim()) | ||
passedComponents.add(matched.split(" ")[0].trim()) | ||
} | ||
|
||
def yamlFile = readYaml(file: args.inputManifestPath) | ||
def currentVersion = yamlFile.build.version | ||
|
||
for (component in yamlFile.components) { | ||
if (passedComponents.contains(component.name)) { | ||
println("Component ${component.name} passed, closing github issue") | ||
ghIssueBody = """Closing the issue as the distribution build for ${component.name} has passed for version: ${currentVersion}. | ||
Please see build log at ${BUILD_URL}consoleFull""".stripIndent() | ||
closeGithubIssue( | ||
repoUrl: component.repository, | ||
issueTitle: "[AUTOCUT] Distribution Build Failed for ${component.name}-${currentVersion}", | ||
closeComment: ghIssueBody, | ||
label: "autocut,v${currentVersion}" | ||
) | ||
sleep(time:3, unit:'SECONDS') | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
/** Library to close GitHub issue across opensearch-project repositories. | ||
@param Map args = [:] args A map of the following parameters | ||
@param args.repoUrl <required> - GitHub repository URL to create issue | ||
@param args.issueTitle <required> - GitHub issue title | ||
@param args.closeComment <required> - GitHub issue leave a closing comment | ||
@param args.label <optional> - GitHub issue label to be attached along with 'untriaged'. Defaults to autocut. | ||
*/ | ||
void call(Map args = [:]) { | ||
label = args.label ?: 'autocut' | ||
try { | ||
withCredentials([usernamePassword(credentialsId: 'jenkins-github-bot-token', passwordVariable: 'GITHUB_TOKEN', usernameVariable: 'GITHUB_USER')]) { | ||
def issues = sh( | ||
script: "gh issue list --repo ${args.repoUrl} -S \"${args.issueTitle} in:title\" --label ${label}", | ||
returnStdout: true | ||
) | ||
def issuesNumber = sh( | ||
script: "gh issue list --repo ${args.repoUrl} -S \"${args.issueTitle} in:title\" --label ${label} --json number --jq '.[0].number'", | ||
returnStdout: true | ||
) | ||
sh( | ||
script: "gh issue close ${issuesNumber} --repo ${args.repoUrl} --comment \"${args.closeComment}\"", | ||
returnStdout: true | ||
) | ||
} | ||
} catch (Exception ex) { | ||
error("Unable to close GitHub issue for ${args.repoUrl}", ex.getMessage()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters