Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <[email protected]>
  • Loading branch information
gaiksaya committed Jul 23, 2024
1 parent 7fe4ad5 commit bb4e733
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
10 changes: 5 additions & 5 deletions jenkins/release-notes-check/release-notes-check.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ pipeline {
script {
if (ACTION.isEmpty() || RELEASE_VERSION.isEmpty()) {
currentBuild.result = 'ABORTED'
error('ACTION or RELEASE_VERSION cannot be empty!')
error('ACTION and RELEASE_VERSION parameters cannot be empty!')
}
if (ACTION == "check" && (COMMENT == "ADD" || GIT_ISSUE_NUMBER.isEmpty())) {
if (ACTION == "check" && (GIT_LOG_DATE.isEmpty() || COMMENT == "ADD" || GIT_ISSUE_NUMBER.isEmpty())) {
currentBuild.result = 'ABORTED'
error('ACTION or COMMENT or GIT_ISSUE_NUMBER cannot be empty!')
error('GIT_LOG_DATE, COMMENT or GIT_ISSUE_NUMBER parameters cannot be empty when ACTION = check!')
}
if (ACTION == "check" && (COMMENT == "UPDATE" || COMMENT_UNIQUE_ID.isEmpty())) {
if (ACTION == "check" && (GIT_LOG_DATE.isEmpty() || COMMENT == "UPDATE" || COMMENT_UNIQUE_ID.isEmpty())) {
currentBuild.result = 'ABORTED'
error('ACTION or COMMENT or COMMENT_UNIQUE_ID cannot be empty!')
error('GIT_LOG_DATE, COMMENT or COMMENT_UNIQUE_ID parameters cannot be empty when ACTION = check!')
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import static com.lesfurets.jenkins.unit.global.lib.GitSource.gitSource
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString
import static org.assertj.core.api.Assertions.assertThat
import static org.hamcrest.CoreMatchers.hasItem
import static org.hamcrest.CoreMatchers.hasItems

class TestReleaseNotesCheck extends BuildPipelineTest {
class TestReleaseNotesCheckAndCompile extends BuildPipelineTest {

String gitLogDate = '2022-10-10'
String comment = 'NO_COMMENT'
Expand Down Expand Up @@ -55,7 +56,11 @@ class TestReleaseNotesCheck extends BuildPipelineTest {
def callStack = helper.getCallStack()
assertCallStack().contains('Check release notes, groovy.lang.Closure')
assertCallStack().contains('Skipping stage Generate consolidated release notes')
assertThat(getShellCommands('release_notes'), hasItem('./release_notes.sh check manifests/3.0.0/opensearch-3.50.yml manifests/3.0.0/opensearch-dashboards-3.0.0.yml --date 2022-10-10'))
assertThat(helper.callStack.findAll { call ->
call.methodName == 'sh'
}.any { call ->
callArgsToString(call).contains('./release_notes.sh check manifests/3.0.0/opensearch-3.0.0.yml manifests/3.0.0/opensearch-dashboards-3.0.0.yml --date 2022-10-10')
}).isTrue()
}

@Test
Expand All @@ -67,8 +72,11 @@ class TestReleaseNotesCheck extends BuildPipelineTest {
def callStack = helper.getCallStack()
assertCallStack().contains('Skipping stage Check release notes')
assertCallStack().contains('Generate consolidated release notes, groovy.lang.Closure')
print(getShellCommands('release_notes'))
assertThat(getShellCommands('release_notes'), hasItem('./release_notes.sh compile manifests/3.0.0/opensearch-3.0.0.yml manifests/3.0.0/opensearch-dashboards-3.0.0.yml --output table.md'))
assertThat(helper.callStack.findAll { call ->
call.methodName == 'sh'
}.any { call ->
callArgsToString(call).contains('./release_notes.sh compile manifests/3.0.0/opensearch-3.0.0.yml manifests/3.0.0/opensearch-dashboards-3.0.0.yml --output table.md')
}).isTrue()
}


Expand Down

0 comments on commit bb4e733

Please sign in to comment.