diff --git a/jenkins/release-notes-check/release-notes-check.jenkinsfile b/jenkins/release-notes-check/release-notes-check.jenkinsfile index 7413dd6f50..1bd95fe695 100644 --- a/jenkins/release-notes-check/release-notes-check.jenkinsfile +++ b/jenkins/release-notes-check/release-notes-check.jenkinsfile @@ -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!') } } } diff --git a/tests/jenkins/TestReleaseNotesCheck.groovy b/tests/jenkins/TestReleaseNotesCheckAndCompile.groovy similarity index 79% rename from tests/jenkins/TestReleaseNotesCheck.groovy rename to tests/jenkins/TestReleaseNotesCheckAndCompile.groovy index c6c4c0238d..1804f815a0 100644 --- a/tests/jenkins/TestReleaseNotesCheck.groovy +++ b/tests/jenkins/TestReleaseNotesCheckAndCompile.groovy @@ -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' @@ -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 @@ -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() }