forked from opensearch-project/opensearch-build-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
closeBuildSuccessGithubIssue.groovy
44 lines (42 loc) · 1.92 KB
/
closeBuildSuccessGithubIssue.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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.search <required> - Filter the logs based on the passed args.search.
@param args.inputManifestPath <required> - Path to input manifest.
*/
void call(Map args = [:]) {
lib = library(identifier: 'jenkins@main', retriever: legacySCM(scm))
def passMessages = args.message
def queryString = args.search
List<String> passedComponents = []
for (message in passMessages.unique()) {
java.util.regex.Matcher match = (message =~ /(?<=\b${queryString}\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')
}
}
}