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) {
def cleanup(configurationMaps) {
Closure cleanupMethod = { configMap ->
sh """
docker exec ${configMap["dockerContainerName"]} bash -c 'rm -rf ~/*' || true
cd ${HOME}/ONNX_CI
./docker.sh chmod --container_name=${configMap["dockerContainerName"]} --directory="/logs" --options="-R 777" || true
./docker.sh stop --container_name=${configMap["dockerContainerName"]} || true
./docker.sh remove --container_name=${configMap["dockerContainerName"]} || true
./docker.sh clean_up || true
rm ${HOME}/ONNX_CI/docker.sh
rm -rf ${HOME}/ONNX_CI/docker.sh
rm -rf ${WORKSPACE}/${BUILD_NUMBER}
"""
}
UTILS.createStage("Cleanup", cleanupMethod, configurationMaps)
UTILS.createStage("Cleanup", cleanupMethod, configurationMaps, true)
}
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) {
......@@ -197,9 +198,9 @@ def main(String label, String projectName, String projectRoot, String dockerCont
runToxTests(configurationMaps)
}
}
catch(e) {
catch(Exception e) {
// 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"
} else {
currentBuild.result = "FAILURE"
......
......@@ -56,7 +56,7 @@ def generateMap(Closure method, configurationMaps) {
return executionMap
}
def createStage(String stageName, Closure method, configurationMaps) {
def createStage(String stageName, Closure method, configurationMaps, force = false) {
/**
* Create pipeline stage.
*
......@@ -71,24 +71,41 @@ def createStage(String stageName, Closure method, configurationMaps) {
configurationMaps[i]["stageName"] = stageName
}
Closure genericBodyMethod = { configMap ->
def status = "SUCCESS"
try {
method(configMap)
} catch(e) {
status = "FAILURE"
throw e
} finally {
UTILS.setConfigurationStatus(configMap["stageName"], configMap["name"], status)
// Fail current stage If earlier stage got aborted or failed
// unless it's executed with force argument set to true
Closure genericBodyMethod = {}
if (!force && ["FAILURE", "ABORTED"].contains(currentBuild.result)) {
genericBodyMethod = { configMap ->
println("Skipping stage due to earlier stage ${currentBuild.result}")
setConfigurationStatus(configMap["stageName"], configMap["name"], currentBuild.result)
throw new Exception("Skipped due to ${currentBuild.result} in earlier stage")
}
}
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 {
def prepareEnvMap = generateMap(genericBodyMethod, configurationMaps)
parallel prepareEnvMap
} catch(e) {
// Set result to ABORTED if exception contains exit code of a process interrupted by SIGTERM
if ("$e".contains("143")) {
} catch(Exception e) {
if (e.toString().contains("FlowInterruptedException")) {
currentBuild.result = "ABORTED"
} else {
currentBuild.result = "FAILURE"
......@@ -108,7 +125,7 @@ def setConfigurationStatus(String stageName, String configurationName, String st
if (!STAGES_STATUS_MAP.containsKey(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()
} else {
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