From 787f8db676cf57a54d04ed5d4bc2614f9db48ce2 Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com> Date: Wed, 13 Dec 2023 16:04:30 -0800 Subject: [PATCH] Move unstable functional call to post always block (#4287) Signed-off-by: Sayali Gaikawad --- .../distribution-build.jenkinsfile | 39 ++++++++++++-- .../opensearch/distribution-build.jenkinsfile | 54 ++++++------------- 2 files changed, 53 insertions(+), 40 deletions(-) diff --git a/jenkins/opensearch-dashboards/distribution-build.jenkinsfile b/jenkins/opensearch-dashboards/distribution-build.jenkinsfile index a7284e6451..8c84f07125 100644 --- a/jenkins/opensearch-dashboards/distribution-build.jenkinsfile +++ b/jenkins/opensearch-dashboards/distribution-build.jenkinsfile @@ -230,6 +230,9 @@ pipeline { "${STAGE_NAME}", lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"]) ) + if (params.CONTINUE_ON_ERROR) { + markStageUnstableIfPluginsFailedToBuild() + } postCleanup() } } @@ -274,7 +277,12 @@ pipeline { } post { always { - postCleanup() + script{ + if (params.CONTINUE_ON_ERROR) { + markStageUnstableIfPluginsFailedToBuild() + } + postCleanup() + } } } } @@ -371,7 +379,12 @@ pipeline { } post { always { - postCleanup() + script{ + if (params.CONTINUE_ON_ERROR) { + markStageUnstableIfPluginsFailedToBuild() + } + postCleanup() + } } } } @@ -465,6 +478,9 @@ pipeline { "${STAGE_NAME}", lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"]) ) + if (params.CONTINUE_ON_ERROR) { + markStageUnstableIfPluginsFailedToBuild() + } postCleanup() } } @@ -591,6 +607,9 @@ pipeline { "${STAGE_NAME}", lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"]) ) + if (params.CONTINUE_ON_ERROR) { + markStageUnstableIfPluginsFailedToBuild() + } postCleanup() } } @@ -688,7 +707,12 @@ pipeline { } post { always { - postCleanup() + script { + if (params.CONTINUE_ON_ERROR) { + markStageUnstableIfPluginsFailedToBuild() + } + postCleanup() + } } } } @@ -785,6 +809,9 @@ pipeline { "${STAGE_NAME}", lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"]) ) + if (params.CONTINUE_ON_ERROR) { + markStageUnstableIfPluginsFailedToBuild() + } postCleanup() } } @@ -935,3 +962,9 @@ pipeline { } } +def markStageUnstableIfPluginsFailedToBuild() { + def stageLogs = getLogsForStage(stageName: "${STAGE_NAME}") + if (stageLogs.any{e -> e.contains('Failed plugins are')}) { + unstable('Some plugins failed to build. See the ./build.sh step for logs and more details') + } +} \ No newline at end of file diff --git a/jenkins/opensearch/distribution-build.jenkinsfile b/jenkins/opensearch/distribution-build.jenkinsfile index 211f28477e..e45e2ee233 100644 --- a/jenkins/opensearch/distribution-build.jenkinsfile +++ b/jenkins/opensearch/distribution-build.jenkinsfile @@ -213,19 +213,15 @@ pipeline { } } post { - success { - script { - if (params.CONTINUE_ON_ERROR) { - markStageUnstableIfPluginsFailedToBuild() - } - } - } always { script { lib.jenkins.Messages.new(this).add( "${STAGE_NAME}", lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"]) ) + if (params.CONTINUE_ON_ERROR) { + markStageUnstableIfPluginsFailedToBuild() + } postCleanup() } } @@ -264,16 +260,14 @@ pipeline { } } post { - success { + always { script { if (params.CONTINUE_ON_ERROR) { markStageUnstableIfPluginsFailedToBuild() } + postCleanup() } } - always { - postCleanup() - } } } stage('assemble-archive-and-test-linux-x64-rpm') { @@ -363,16 +357,14 @@ pipeline { } } post { - success { + always { script { if (params.CONTINUE_ON_ERROR) { markStageUnstableIfPluginsFailedToBuild() } + postCleanup() } } - always { - postCleanup() - } } } stage('assemble-archive-and-test-linux-x64-deb') { @@ -472,19 +464,15 @@ pipeline { } } post { - success { - script { - if (params.CONTINUE_ON_ERROR) { - markStageUnstableIfPluginsFailedToBuild() - } - } - } always { script { lib.jenkins.Messages.new(this).add( "${STAGE_NAME}", lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"]) ) + if (params.CONTINUE_ON_ERROR) { + markStageUnstableIfPluginsFailedToBuild() + } postCleanup() } } @@ -523,16 +511,14 @@ pipeline { } } post { - success { + always { script { if (params.CONTINUE_ON_ERROR) { markStageUnstableIfPluginsFailedToBuild() } + postCleanup() } } - always { - postCleanup() - } } } stage('assemble-archive-and-test-linux-arm64-rpm') { @@ -622,16 +608,14 @@ pipeline { } } post { - success { + always { script { if (params.CONTINUE_ON_ERROR) { markStageUnstableIfPluginsFailedToBuild() } + postCleanup() } } - always { - postCleanup() - } } } stage('assemble-archive-and-test-linux-arm64-deb') { @@ -715,19 +699,15 @@ pipeline { } } post { - success { - script { - if (params.CONTINUE_ON_ERROR) { - markStageUnstableIfPluginsFailedToBuild() - } - } - } always { script { lib.jenkins.Messages.new(this).add( "${STAGE_NAME}", lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"]) ) + if (params.CONTINUE_ON_ERROR) { + markStageUnstableIfPluginsFailedToBuild() + } postCleanup() } }