-
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.
Update the
AUTOCUT
issues with the latest build fail information (#253
) Signed-off-by: Prudhvi Godithi <[email protected]> (cherry picked from commit a312326) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3a73bf6
commit f7279cf
Showing
24 changed files
with
439 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package jenkins.tests | ||
|
||
import jenkins.tests.BuildPipelineTest | ||
import org.junit.Before | ||
import org.junit.Test | ||
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString | ||
import static org.hamcrest.CoreMatchers.hasItem | ||
import static org.hamcrest.MatcherAssert.assertThat | ||
|
||
class TestCloseBuildSuccessGithubIssue extends BuildPipelineTest { | ||
|
||
@Override | ||
@Before | ||
void setUp() { | ||
this.registerLibTester(new CloseBuildSuccessGithubIssueLibTester(['Build successful OpenSearch'])) | ||
super.setUp() | ||
} | ||
|
||
|
||
@Test | ||
public void testExistingGithubIssue() { | ||
super.testPipeline('tests/jenkins/jobs/CloseBuildSuccessGithubIssue_JenkinsFile') | ||
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue list --repo https://github.com/opensearch-project/OpenSearch.git -S \"[AUTOCUT] Distribution Build Failed for OpenSearch-2.0.0 in:title\" --label autocut,v2.0.0 --json number --jq '.[0].number', returnStdout=true}")) | ||
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue close bbb\nccc -R opensearch-project/OpenSearch --comment \"Closing the issue as the distribution build for OpenSearch has passed for version: **2.0.0**.\n Please see build log at www.example.com/jobs/test/123/consoleFull\", returnStdout=true}")) | ||
} | ||
|
||
def getCommands(method, text) { | ||
def shCommands = helper.callStack.findAll { call -> | ||
call.methodName == method | ||
}.collect { call -> | ||
callArgsToString(call) | ||
}.findAll { command -> | ||
command.contains(text) | ||
} | ||
return shCommands | ||
} | ||
|
||
} |
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,51 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package jenkins.tests | ||
|
||
import jenkins.tests.BuildPipelineTest | ||
import org.junit.Before | ||
import org.junit.Test | ||
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString | ||
import static org.hamcrest.CoreMatchers.hasItem | ||
import static org.hamcrest.MatcherAssert.assertThat | ||
|
||
class TestCloseGithubIssue extends BuildPipelineTest { | ||
|
||
@Override | ||
@Before | ||
void setUp() { | ||
super.setUp() | ||
} | ||
|
||
|
||
@Test | ||
void testCloseExistingGithubIssue() { | ||
this.registerLibTester(new CloseGithubIssueLibTester( | ||
'https://github.com/opensearch-project/opensearch-build', | ||
'Test GH issue title', | ||
'Test GH issue close comment', | ||
'label101', | ||
)) | ||
super.testPipeline("tests/jenkins/jobs/CloseGithubIssue_JenkinsFile") | ||
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue list --repo https://github.com/opensearch-project/opensearch-build -S \"Test GH issue title in:title\" --label label101 --json number --jq '.[0].number', returnStdout=true}")) | ||
assertThat(getCommands('sh', 'script'), hasItem("{script=gh issue close bbb\nccc -R opensearch-project/opensearch-build --comment \"Test GH issue close comment\", returnStdout=true}")) | ||
} | ||
|
||
def getCommands(method, text) { | ||
def shCommands = helper.callStack.findAll { call -> | ||
call.methodName == method | ||
}.collect { call -> | ||
callArgsToString(call) | ||
}.findAll { command -> | ||
command.contains(text) | ||
} | ||
return shCommands | ||
} | ||
|
||
} |
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,6 @@ | ||
BuildMessage_Jenkinsfile.run() | ||
BuildMessage_Jenkinsfile.pipeline(groovy.lang.Closure) | ||
BuildMessage_Jenkinsfile.echo(Executing on agent [label:none]) | ||
BuildMessage_Jenkinsfile.stage(notify, groovy.lang.Closure) | ||
BuildMessage_Jenkinsfile.script(groovy.lang.Closure) | ||
BuildMessage_Jenkinsfile.buildMessage({search=pass}) |
24 changes: 24 additions & 0 deletions
24
tests/jenkins/jobs/CloseBuildSuccessGithubIssue_JenkinsFile
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,24 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
pipeline { | ||
agent none | ||
stages { | ||
stage('notify') { | ||
steps { | ||
script { | ||
closeBuildSuccessGithubIssue( | ||
message: ["Build successful OpenSearch"], | ||
inputManifestPath: 'tests/data/opensearch-2.0.0.yml' | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/jenkins/jobs/CloseBuildSuccessGithubIssue_JenkinsFile.txt
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,18 @@ | ||
CloseBuildSuccessGithubIssue_JenkinsFile.run() | ||
CloseBuildSuccessGithubIssue_JenkinsFile.pipeline(groovy.lang.Closure) | ||
CloseBuildSuccessGithubIssue_JenkinsFile.echo(Executing on agent [label:none]) | ||
CloseBuildSuccessGithubIssue_JenkinsFile.stage(notify, groovy.lang.Closure) | ||
CloseBuildSuccessGithubIssue_JenkinsFile.script(groovy.lang.Closure) | ||
CloseBuildSuccessGithubIssue_JenkinsFile.closeBuildSuccessGithubIssue({message=[Build successful OpenSearch], inputManifestPath=tests/data/opensearch-2.0.0.yml}) | ||
closeBuildSuccessGithubIssue.legacySCM(groovy.lang.Closure) | ||
closeBuildSuccessGithubIssue.library({identifier=jenkins@main, retriever=null}) | ||
closeBuildSuccessGithubIssue.readYaml({file=tests/data/opensearch-2.0.0.yml}) | ||
closeBuildSuccessGithubIssue.closeGithubIssue({repoUrl=https://github.com/opensearch-project/OpenSearch.git, issueTitle=[AUTOCUT] Distribution Build Failed for OpenSearch-2.0.0, closeComment=Closing the issue as the distribution build for OpenSearch has passed for version: **2.0.0**. | ||
Please see build log at www.example.com/jobs/test/123/consoleFull, label=autocut,v2.0.0}) | ||
closeGithubIssue.usernamePassword({credentialsId=jenkins-github-bot-token, passwordVariable=GITHUB_TOKEN, usernameVariable=GITHUB_USER}) | ||
closeGithubIssue.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure) | ||
closeGithubIssue.sh({script=gh issue list --repo https://github.com/opensearch-project/OpenSearch.git -S "[AUTOCUT] Distribution Build Failed for OpenSearch-2.0.0 in:title" --label autocut,v2.0.0 --json number --jq '.[0].number', returnStdout=true}) | ||
closeGithubIssue.sh({script=gh issue close bbb | ||
ccc -R opensearch-project/OpenSearch --comment "Closing the issue as the distribution build for OpenSearch has passed for version: **2.0.0**. | ||
Please see build log at www.example.com/jobs/test/123/consoleFull", returnStdout=true}) | ||
closeBuildSuccessGithubIssue.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,26 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
pipeline { | ||
agent none | ||
stages { | ||
stage('closeGithubIssue') { | ||
steps { | ||
script { | ||
closeGithubIssue( | ||
repoUrl: 'https://github.com/opensearch-project/opensearch-build', | ||
issueTitle: 'Test GH issue title', | ||
closeComment: 'Test GH issue close comment', | ||
label: 'label101' | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
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,11 @@ | ||
CloseGithubIssue_JenkinsFile.run() | ||
CloseGithubIssue_JenkinsFile.pipeline(groovy.lang.Closure) | ||
CloseGithubIssue_JenkinsFile.echo(Executing on agent [label:none]) | ||
CloseGithubIssue_JenkinsFile.stage(closeGithubIssue, groovy.lang.Closure) | ||
CloseGithubIssue_JenkinsFile.script(groovy.lang.Closure) | ||
CloseGithubIssue_JenkinsFile.closeGithubIssue({repoUrl=https://github.com/opensearch-project/opensearch-build, issueTitle=Test GH issue title, closeComment=Test GH issue close comment, label=label101}) | ||
closeGithubIssue.usernamePassword({credentialsId=jenkins-github-bot-token, passwordVariable=GITHUB_TOKEN, usernameVariable=GITHUB_USER}) | ||
closeGithubIssue.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure) | ||
closeGithubIssue.sh({script=gh issue list --repo https://github.com/opensearch-project/opensearch-build -S "Test GH issue title in:title" --label label101 --json number --jq '.[0].number', returnStdout=true}) | ||
closeGithubIssue.sh({script=gh issue close bbb | ||
ccc -R opensearch-project/opensearch-build --comment "Test GH issue close comment", returnStdout=true}) |
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
31 changes: 0 additions & 31 deletions
31
tests/jenkins/lib-testers/BuildFailureMessageLibTester.groovy
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.