Skip to content

Commit

Permalink
[Backport 7.x] Remove labels arg for closing GH issue (#533)
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent ad1597b commit c594197
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jacocoTestReport {
}
}

String version = '7.0.1'
String version = '7.1.0'

task updateVersion {
doLast {
Expand Down
3 changes: 1 addition & 2 deletions tests/jenkins/TestCloseGithubIssue.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class TestCloseGithubIssue extends BuildPipelineTest {
this.registerLibTester(new CloseGithubIssueLibTester(
'https://github.com/opensearch-project/opensearch-build',
'Test GH issue title',
'Test GH issue close comment',
'label101',
'Test GH issue close comment'
))
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\" --json number --jq '.[0].number', returnStdout=true}"))
Expand Down
3 changes: 1 addition & 2 deletions tests/jenkins/jobs/CloseGithubIssue_JenkinsFile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ pipeline {
closeGithubIssue(
repoUrl: 'https://github.com/opensearch-project/opensearch-build',
issueTitle: 'Test GH issue title',
closeComment: 'Test GH issue close comment',
label: 'label101'
closeComment: 'Test GH issue close comment'
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/jobs/CloseGithubIssue_JenkinsFile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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_JenkinsFile.closeGithubIssue({repoUrl=https://github.com/opensearch-project/opensearch-build, issueTitle=Test GH issue title, closeComment=Test GH issue close comment})
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" --json number --jq '.[0].number', returnStdout=true})
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/jobs/UpdateBuildFailureIssue_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ccc --repo https://github.com/opensearch-project/asynchronous-search.git --body
Checkout the [wiki](https://github.com/opensearch-project/opensearch-build/wiki/Building-an-OpenSearch-and-OpenSearch-Dashboards-Distribution) to reproduce the failure locally.", returnStdout=true})
updateBuildFailureIssues.sleep({time=3, unit=SECONDS})
updateBuildFailureIssues.closeGithubIssue({repoUrl=https://github.com/opensearch-project/sql.git, issueTitle=[AUTOCUT] Distribution Build Failed for sql-2.2.0, closeComment=Closing the issue as the distribution build for sql has passed for version: **2.2.0**.
Please see build log at www.example.com/job/build_url/32/display/redirect, label=autocut,v2.2.0})
Please see build log at www.example.com/job/build_url/32/display/redirect})
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/sql.git -S "[AUTOCUT] Distribution Build Failed for sql-2.2.0 in:title" --json number --jq '.[0].number', returnStdout=true})
Expand Down
8 changes: 2 additions & 6 deletions tests/jenkins/lib-testers/CloseGithubIssueLibTester.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ class CloseGithubIssueLibTester extends LibFunctionTester {
private String repoUrl
private String issueTitle
private String closeComment
private String label

public CloseGithubIssueLibTester(repoUrl, issueTitle, closeComment, label){
public CloseGithubIssueLibTester(repoUrl, issueTitle, closeComment){
this.repoUrl = repoUrl
this.issueTitle = issueTitle
this.closeComment = closeComment
this.label = label
}


Expand All @@ -35,13 +33,11 @@ class CloseGithubIssueLibTester extends LibFunctionTester {
assertThat(call.args.repoUrl.first(), notNullValue())
assertThat(call.args.issueTitle.first(), notNullValue())
assertThat(call.args.closeComment.first(), notNullValue())
assertThat(call.args.label.first(), notNullValue())
}

@Override
boolean expectedParametersMatcher(Object call) {
return call.args.label.first().equals(this.label)
&& call.args.repoUrl.first().equals(this.repoUrl)
return call.args.repoUrl.first().equals(this.repoUrl)
&& call.args.issueTitle.first().equals(this.issueTitle)
&& call.args.closeComment.first().equals(this.closeComment)
}
Expand Down
2 changes: 0 additions & 2 deletions vars/closeGithubIssue.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
@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 issuesNumber = sh(
Expand Down
3 changes: 1 addition & 2 deletions vars/updateBuildFailureIssues.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ void call(Map args = [:]) {
closeGithubIssue(
repoUrl: component.repository,
issueTitle: "[AUTOCUT] Distribution Build Failed for ${component.name}-${currentVersion}",
closeComment: ghIssueBody,
label: "autocut,v${currentVersion}"
closeComment: ghIssueBody
)
sleep(time:3, unit:'SECONDS')
}
Expand Down

0 comments on commit c594197

Please sign in to comment.