This is an automated email from the ASF dual-hosted git repository.
jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 4c0df62 Kill running PR builds when a new build is triggered for the
same PR (#8034)
4c0df62 is described below
commit 4c0df6249d03841f5eb30e1428aa25fc230fed30
Author: mbaijal <[email protected]>
AuthorDate: Tue Sep 26 16:10:56 2017 -0700
Kill running PR builds when a new build is triggered for the same PR (#8034)
* Kill running PR builds when a new build is triggered for the same PR
* Merge the Purge Stage into Sanity Test
* ReviewComments: 1. Does not abort on branch master; 2. Added Comments; 3.
checks for build# < currentBuild; 4. removed else part of print; 5. Changed
variable names
---
Jenkinsfile | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index eb82e00..0574896 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -11,6 +11,30 @@ max_time = 120
// assign any caught errors here
err = null
+//Method to Kill old PR Builds that are running currently when a new build is
triggered.
+//env.JOB_NAME looks something like "incubator-mxnet/PR-7893". Thus,
projectName is incubator-mxnet
+//env.JOB_BASE_NAME is either the name of the branch or for a PR something
like "PR-7893"
+//Once the project and the current PR (or branch) is known, search for all
builds within it.
+//Abort the build if it is older than the current build.
+def abortPreviousRunningBuilds() {
+ def hudsonInstance = Hudson.instance
+ def projectName = env.JOB_NAME.split('/')[0]
+
+
hudsonInstance.getItem(projectName).getItem(env.JOB_BASE_NAME).getBuilds().each{
build ->
+ def exec = build.getExecutor()
+
+ if (build.number < currentBuild.number && exec != null) {
+ exec.interrupt(
+ Result.ABORTED,
+ new CauseOfInterruption.UserInterruption(
+ "Aborted by #${currentBuild.number}"
+ )
+ )
+ println("Aborted previous running build #${build.number}")
+ }
+ }
+}
+
// initialize source codes
def init_git() {
retry(5) {
@@ -18,7 +42,7 @@ def init_git() {
timeout(time: 2, unit: 'MINUTES') {
checkout scm
sh 'git submodule update --init'
- sh 'git clean -d -f'
+ sh 'git clean -d -f'
}
} catch (exc) {
deleteDir()
@@ -34,7 +58,7 @@ def init_git_win() {
timeout(time: 2, unit: 'MINUTES') {
checkout scm
bat 'git submodule update --init'
- bat 'git clean -d -f'
+ bat 'git clean -d -f'
}
} catch (exc) {
deleteDir()
@@ -119,6 +143,9 @@ try {
stage("Sanity Check") {
timeout(time: max_time, unit: 'MINUTES') {
node('mxnetlinux') {
+ if (env.BRANCH_NAME != "master") {
+ abortPreviousRunningBuilds()
+ }
ws('workspace/sanity') {
init_git()
sh "python tools/license_header.py check"
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].