Skip to content

Commit

Permalink
Move unstable functional call to post always block (#4287)
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <gaiksaya@amazon.com>
  • Loading branch information
gaiksaya authored Dec 14, 2023
1 parent 44e2903 commit 787f8db
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 40 deletions.
39 changes: 36 additions & 3 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ pipeline {
"${STAGE_NAME}",
lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"])
)
if (params.CONTINUE_ON_ERROR) {
markStageUnstableIfPluginsFailedToBuild()
}
postCleanup()
}
}
Expand Down Expand Up @@ -274,7 +277,12 @@ pipeline {
}
post {
always {
postCleanup()
script{
if (params.CONTINUE_ON_ERROR) {
markStageUnstableIfPluginsFailedToBuild()
}
postCleanup()
}
}
}
}
Expand Down Expand Up @@ -371,7 +379,12 @@ pipeline {
}
post {
always {
postCleanup()
script{
if (params.CONTINUE_ON_ERROR) {
markStageUnstableIfPluginsFailedToBuild()
}
postCleanup()
}
}
}
}
Expand Down Expand Up @@ -465,6 +478,9 @@ pipeline {
"${STAGE_NAME}",
lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"])
)
if (params.CONTINUE_ON_ERROR) {
markStageUnstableIfPluginsFailedToBuild()
}
postCleanup()
}
}
Expand Down Expand Up @@ -591,6 +607,9 @@ pipeline {
"${STAGE_NAME}",
lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"])
)
if (params.CONTINUE_ON_ERROR) {
markStageUnstableIfPluginsFailedToBuild()
}
postCleanup()
}
}
Expand Down Expand Up @@ -688,7 +707,12 @@ pipeline {
}
post {
always {
postCleanup()
script {
if (params.CONTINUE_ON_ERROR) {
markStageUnstableIfPluginsFailedToBuild()
}
postCleanup()
}
}
}
}
Expand Down Expand Up @@ -785,6 +809,9 @@ pipeline {
"${STAGE_NAME}",
lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"])
)
if (params.CONTINUE_ON_ERROR) {
markStageUnstableIfPluginsFailedToBuild()
}
postCleanup()
}
}
Expand Down Expand Up @@ -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')
}
}
54 changes: 17 additions & 37 deletions jenkins/opensearch/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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()
}
}
Expand Down

0 comments on commit 787f8db

Please sign in to comment.