Skip to content

Commit

Permalink
Add pipeline publish link warning if job fails
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Leonard <[email protected]>
  • Loading branch information
andrew-m-leonard committed Nov 21, 2024
1 parent 54f0fe1 commit 2ba8f15
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pipelines/build/common/build_base_file.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -781,11 +781,11 @@ class Builder implements Serializable {
def javaVersion=determineReleaseToolRepoVersion()
def stageName = 'BETA publish'
def releaseComment = 'BETA publish'
def prefixLinkComment = ''
def releaseWarning = ''
if ( jobResult != "SUCCESS" && jobResult != "UNSTABLE" ) {
// Build was not successful, add warning and link to build job
def buildUrl = "${context.JENKINS_URL}${jobUrl}"
prefixLinkComment = '<a href=${buildUrl}><span style="color:red;">WARNING: build result(<b>' + jobResult + '</b>)</span></a> : '
releaseWarning = '<a href=' + buildUrl + '><span style="color:red;">WARNING: build result(<b>' + jobResult + '</b>)</span></a> : '
}

def tag = "${javaToBuild}-${timestamp}"
Expand Down Expand Up @@ -829,17 +829,14 @@ class Builder implements Serializable {
}
}

// Add any prefix comment
releaseComment = prefixLinkComment + releaseComment

releaseToolUrl += "VERSION=${javaVersion}&RELEASE=${release}&UPSTREAM_JOB_NUMBER=${currentBuild.getNumber()}"
tag = URLEncoder.encode(tag, 'UTF-8')
artifactsToCopy = URLEncoder.encode(artifactsToCopy, 'UTF-8')
def urlJobName = URLEncoder.encode("${env.JOB_NAME}", 'UTF-8')
releaseToolUrl += "&TAG=${tag}&UPSTREAM_JOB_NAME=${urlJobName}&ARTIFACTS_TO_COPY=${artifactsToCopy}"

context.echo "return releaseToolUrl is ${releaseToolUrl}"
return ["${releaseToolUrl}", "${releaseComment}"]
return ["${releaseToolUrl}", "${releaseComment}", "${releaseWarning}"]
}

/*
Expand Down Expand Up @@ -986,8 +983,8 @@ class Builder implements Serializable {

copyArtifactSuccess = true
if (release) {
def (String releaseToolUrl, String releaseComment) = publishBinary(config, downstreamJob.getResult(), downstreamJob.getAbsoluteUrl())
releaseSummary.appendText("<li><a href=${releaseToolUrl}> ${releaseComment} ${config.VARIANT} ${publishName} ${config.TARGET_OS} ${config.ARCHITECTURE}</a></li>")
def (String releaseToolUrl, String releaseComment, String releaseWarning) = publishBinary(config, downstreamJob.getResult(), downstreamJob.getAbsoluteUrl())
releaseSummary.appendText("<li>${releaseWarning}<a href=${releaseToolUrl}> ${releaseComment} ${config.VARIANT} ${publishName} ${config.TARGET_OS} ${config.ARCHITECTURE}</a></li>")
}
}
}
Expand Down Expand Up @@ -1068,8 +1065,8 @@ class Builder implements Serializable {
} else {
try {
context.timeout(time: pipelineTimeouts.PUBLISH_ARTIFACTS_TIMEOUT, unit: 'HOURS') {
def (String releaseToolUrl, String releaseComment) = publishBinary(null, currentBuild.result, "${context.JOB_URL}")
releaseSummary.appendText("<li><a href=${releaseToolUrl}> ${releaseComment} Rerun Link</a></li>")
def (String releaseToolUrl, String releaseComment, String releaseWarning) = publishBinary(null, currentBuild.result, "${context.JOB_URL}")
releaseSummary.appendText("<li>${releaseWarning}<a href=${releaseToolUrl}> ${releaseComment} Rerun Link</a></li>")
}
} catch (FlowInterruptedException e) {
throw new Exception("[ERROR] Publish binary timeout (${pipelineTimeouts.PUBLISH_ARTIFACTS_TIMEOUT} HOURS) has been reached OR the downstream publish job failed. Exiting...")
Expand Down

0 comments on commit 2ba8f15

Please sign in to comment.