Commit f9bed8c4 authored by mchrusci's avatar mchrusci Committed by Robert Kimball

[ONNX CI] Update ONNX CI - no email notification after aborted build (#2599)

* Update ONNX CI

Don't send email notification when build was aborted.

* Added force parameter

* Cleanup workspace

* Cleanup docker container workspace
parent 6b5016e5
...@@ -135,16 +135,17 @@ def runToxTests(configurationMaps) { ...@@ -135,16 +135,17 @@ def runToxTests(configurationMaps) {
def cleanup(configurationMaps) { def cleanup(configurationMaps) {
Closure cleanupMethod = { configMap -> Closure cleanupMethod = { configMap ->
sh """ sh """
docker exec ${configMap["dockerContainerName"]} bash -c 'rm -rf ~/*' || true
cd ${HOME}/ONNX_CI cd ${HOME}/ONNX_CI
./docker.sh chmod --container_name=${configMap["dockerContainerName"]} --directory="/logs" --options="-R 777" || true ./docker.sh chmod --container_name=${configMap["dockerContainerName"]} --directory="/logs" --options="-R 777" || true
./docker.sh stop --container_name=${configMap["dockerContainerName"]} || true ./docker.sh stop --container_name=${configMap["dockerContainerName"]} || true
./docker.sh remove --container_name=${configMap["dockerContainerName"]} || true ./docker.sh remove --container_name=${configMap["dockerContainerName"]} || true
./docker.sh clean_up || true ./docker.sh clean_up || true
rm ${HOME}/ONNX_CI/docker.sh rm -rf ${HOME}/ONNX_CI/docker.sh
rm -rf ${WORKSPACE}/${BUILD_NUMBER} rm -rf ${WORKSPACE}/${BUILD_NUMBER}
""" """
} }
UTILS.createStage("Cleanup", cleanupMethod, configurationMaps) UTILS.createStage("Cleanup", cleanupMethod, configurationMaps, true)
} }
def notifyByEmail() { def notifyByEmail() {
...@@ -173,7 +174,7 @@ def notifyByEmail() { ...@@ -173,7 +174,7 @@ def notifyByEmail() {
) )
} }
} }
UTILS.createStage("Notify", notifyMethod, configurationMaps) UTILS.createStage("Notify", notifyMethod, configurationMaps, true)
} }
def main(String label, String projectName, String projectRoot, String dockerContainerName, String jenkins_github_credential_id, String ngraph_git_address, String onnx_git_address) { def main(String label, String projectName, String projectRoot, String dockerContainerName, String jenkins_github_credential_id, String ngraph_git_address, String onnx_git_address) {
...@@ -197,9 +198,9 @@ def main(String label, String projectName, String projectRoot, String dockerCont ...@@ -197,9 +198,9 @@ def main(String label, String projectName, String projectRoot, String dockerCont
runToxTests(configurationMaps) runToxTests(configurationMaps)
} }
} }
catch(e) { catch(Exception e) {
// Set result to ABORTED if exception contains exit code of a process interrupted by SIGTERM // Set result to ABORTED if exception contains exit code of a process interrupted by SIGTERM
if ("$e".contains("143")) { if (e.toString().contains("FlowInterruptedException")) {
currentBuild.result = "ABORTED" currentBuild.result = "ABORTED"
} else { } else {
currentBuild.result = "FAILURE" currentBuild.result = "FAILURE"
......
...@@ -56,7 +56,7 @@ def generateMap(Closure method, configurationMaps) { ...@@ -56,7 +56,7 @@ def generateMap(Closure method, configurationMaps) {
return executionMap return executionMap
} }
def createStage(String stageName, Closure method, configurationMaps) { def createStage(String stageName, Closure method, configurationMaps, force = false) {
/** /**
* Create pipeline stage. * Create pipeline stage.
* *
...@@ -71,24 +71,41 @@ def createStage(String stageName, Closure method, configurationMaps) { ...@@ -71,24 +71,41 @@ def createStage(String stageName, Closure method, configurationMaps) {
configurationMaps[i]["stageName"] = stageName configurationMaps[i]["stageName"] = stageName
} }
Closure genericBodyMethod = { configMap -> // Fail current stage If earlier stage got aborted or failed
def status = "SUCCESS" // unless it's executed with force argument set to true
try { Closure genericBodyMethod = {}
method(configMap) if (!force && ["FAILURE", "ABORTED"].contains(currentBuild.result)) {
} catch(e) { genericBodyMethod = { configMap ->
status = "FAILURE" println("Skipping stage due to earlier stage ${currentBuild.result}")
throw e setConfigurationStatus(configMap["stageName"], configMap["name"], currentBuild.result)
} finally { throw new Exception("Skipped due to ${currentBuild.result} in earlier stage")
UTILS.setConfigurationStatus(configMap["stageName"], configMap["name"], status) }
}
else
{
genericBodyMethod = { configMap ->
def status = "SUCCESS"
try {
method(configMap)
} catch(Exception e) {
if (e.toString().contains("FlowInterruptedException")) {
status = "ABORTED"
} else {
status = "FAILURE"
}
currentBuild.result = status
throw e
} finally {
setConfigurationStatus(configMap["stageName"], configMap["name"], status)
}
} }
} }
try { try {
def prepareEnvMap = generateMap(genericBodyMethod, configurationMaps) def prepareEnvMap = generateMap(genericBodyMethod, configurationMaps)
parallel prepareEnvMap parallel prepareEnvMap
} catch(e) { } catch(Exception e) {
// Set result to ABORTED if exception contains exit code of a process interrupted by SIGTERM if (e.toString().contains("FlowInterruptedException")) {
if ("$e".contains("143")) {
currentBuild.result = "ABORTED" currentBuild.result = "ABORTED"
} else { } else {
currentBuild.result = "FAILURE" currentBuild.result = "FAILURE"
...@@ -108,7 +125,7 @@ def setConfigurationStatus(String stageName, String configurationName, String st ...@@ -108,7 +125,7 @@ def setConfigurationStatus(String stageName, String configurationName, String st
if (!STAGES_STATUS_MAP.containsKey(stageName)) { if (!STAGES_STATUS_MAP.containsKey(stageName)) {
STAGES_STATUS_MAP[stageName] = [:] STAGES_STATUS_MAP[stageName] = [:]
} }
if (["FAILURE", "SUCCESS"].contains(status.toUpperCase())) { if (["FAILURE", "SUCCESS", "ABORTED"].contains(status.toUpperCase())) {
STAGES_STATUS_MAP[stageName][configurationName] = status.toUpperCase() STAGES_STATUS_MAP[stageName][configurationName] = status.toUpperCase()
} else { } else {
throw new Exception("Not supported status name.") throw new Exception("Not supported status name.")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment