marcoabreu commented on a change in pull request #17999: For mxnet-validation 
pipeline, require sanity build to complete successfully before running other 
build pipelines.
URL: https://github.com/apache/incubator-mxnet/pull/17999#discussion_r406149155
 
 

 ##########
 File path: ci/Jenkinsfile_utils.groovy
 ##########
 @@ -261,6 +261,41 @@ def assign_node_labels(args) {
   NODE_UTILITY = args.utility
 }
 
+def sanity_build_running(pr) {
+    def retVal = "UNKNOWN"
+    try {
+        def prSanityBuild = 
Jenkins.instance.getItem("mxnet-validation").getItem("sanity").getItem(pr)
+        if (prSanityBuild.isBuilding() || prSanityBuild.isInQueue()) {
+            echo "Sanity build " + prSanityBuild.getLastBuild().number + " 
currently running"
+            retVal = "RUNNING"
+        } else {
+            retVal = prSanityBuild.getLastBuild().result.toString()
+        }
+    } catch (checkError) {
+        echo "Caught exception trying to find sanity build for this PR, 
continuing build without delay."
+    }
+    return retVal
+}
+
+def wait_for_sanity_builds() {
+    if (env.CHANGE_ID && env.JOB_NAME.lastIndexOf("PR-") != -1) {
+        echo "This is a pull request (PR-${env.CHANGE_ID}), checking for 
running sanity build."
+        // sleep to make sure sanity job is created
+        sleep(10)
+        def PRNum = env.JOB_NAME.substring(env.JOB_NAME.lastIndexOf("PR-"))
+        def buildStatus = sanity_build_running(PRNum)
+        while (buildStatus.equals("RUNNING")) {
+            sleep(20)
+            buildStatus = sanity_build_running(PRNum)
+        }
+        echo "Sanity build result: " + buildStatus
+        if (buildStatus.equals("FAILURE") || buildStatus.equals("ABORTED")) {
 
 Review comment:
   Check for success, not for failure. The default should be to stop if 
something unexpected happened, not to continue.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to