From 114fe2d5ba7b0bf2b50afc848df8dd5e06d02de0 Mon Sep 17 00:00:00 2001 From: Larry Grill Date: Fri, 23 Mar 2018 12:15:46 -0400 Subject: [PATCH 1/8] [CLEANUP] Skip unit and artifact archiving for NOOP builds --- Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 74e1c655d..b9e7fed66 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -137,7 +137,7 @@ pipeline { stage('Archive Test Results') { when { expression { - return params.RUN_UNIT_TESTS + return (params.ARCHIVE_ARTIFACTS && !params.NOOP) } } steps { @@ -148,13 +148,12 @@ pipeline { stage('Archive Build Artifacts') { when { expression { - return params.ARCHIVE_ARTIFACTS + return (params.ARCHIVE_ARTIFACTS && !params.NOOP) } } steps { archiveArtifacts artifacts: '**/target/**/*.gz, **/target/**/*.tar.gz, **/target/**/*.zip', fingerprint: false } } - } } From 9e9b56aa831f142709bfb520bfd1781627a36087 Mon Sep 17 00:00:00 2001 From: Larry Grill Date: Fri, 23 Mar 2018 12:33:36 -0400 Subject: [PATCH 2/8] [CLEANUP] Move mapped build data gen to doConfig method --- Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b9e7fed66..b2c2b24f6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,8 +1,7 @@ @Library ('jenkins-shared-libraries') _ -import org.hvbuilders.MappedBuildData - -MappedBuildData mbd = new MappedBuildData() +// We need a global mapped build data object to pass down through the stages of the build +def mappedBuildData pipeline { @@ -97,7 +96,7 @@ pipeline { script{ String dataFilePath = "${WORKSPACE}/resources/builders/${params.BUILD_DATA_FILE}" println "doBuild: Loading build data from ${dataFilePath}" - mbd.createMappedData( dataFilePath ) + mappedBuildData = doConfig(dataFilePath) } } } @@ -108,7 +107,7 @@ pipeline { } } steps { - doCheckouts(mbd) + doCheckouts(mappedBuildData) } } @@ -119,7 +118,7 @@ pipeline { } } steps { - doBuilds(mbd) + doBuilds(mappedBuildData) } } @@ -130,7 +129,7 @@ pipeline { } } steps { - doUnitTests(mbd) + doUnitTests(mappedBuildData) } } @@ -155,5 +154,6 @@ pipeline { archiveArtifacts artifacts: '**/target/**/*.gz, **/target/**/*.tar.gz, **/target/**/*.zip', fingerprint: false } } + } } From ed2d1aa0590c24d140ce785dda577d8857b2b6ef Mon Sep 17 00:00:00 2001 From: Larry Grill Date: Sun, 25 Mar 2018 10:18:51 -0400 Subject: [PATCH 3/8] [CLEANUP] Move mapped build data gen to doConfig method * Add some post build boiler plate * Bit of additional cleanup --- Jenkinsfile | 43 ++++++++++++++++--- .../builders/thinBuildControlDataTest.yaml | 6 --- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b2c2b24f6..a6479d428 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,12 +32,15 @@ pipeline { string(defaultValue: 'maven3-auto', description: 'Use this Jenkins Maven label for builds', name: 'JENKINS_MAVEN_FOR_BUILDS') - booleanParam(defaultValue: false, description: 'Clean all build dependency caches', name: 'CLEAN_ALL_CACHES') - booleanParam(defaultValue: false, description: 'Clean build scm workspaces', name: 'CLEAN_SCM_WORKSPACES') booleanParam(defaultValue: true, description: 'Run the scm checkouts', name: 'RUN_CHECKOUTS') booleanParam(defaultValue: true, description: 'Run the code builds', name: 'RUN_BUILDS') booleanParam(defaultValue: true, description: 'Run the code tests', name: 'RUN_UNIT_TESTS') booleanParam(defaultValue: true, description: 'Archive the artifacts', name: 'ARCHIVE_ARTIFACTS') + + booleanParam(defaultValue: false, description: 'Clean all build dependency caches', name: 'CLEAN_ALL_CACHES') + booleanParam(defaultValue: false, description: 'Clean build scm workspaces', name: 'CLEAN_SCM_WORKSPACES') + booleanParam(defaultValue: false, description: 'Clean build buuild workspace (this happens post build)', name: 'CLEAN_BUILD_WORKSPACE') + booleanParam(defaultValue: false, description: 'No op build (test the build config)', name: 'NOOP') booleanParam(defaultValue: false, description: 'Distributes source checkouts on remote nodes ' + '(Otherwise assume workspace is shared on all). Not yet fully implmented--do not use.', name: 'USE_DISTRIBUTED_SOURCE_CACHING') @@ -94,12 +97,11 @@ pipeline { stage('Configure'){ steps { script{ - String dataFilePath = "${WORKSPACE}/resources/builders/${params.BUILD_DATA_FILE}" - println "doBuild: Loading build data from ${dataFilePath}" - mappedBuildData = doConfig(dataFilePath) + mappedBuildData = doConfig("${WORKSPACE}/resources/builders/${params.BUILD_DATA_FILE}") } } } + stage('Checkouts'){ when { expression { @@ -144,7 +146,7 @@ pipeline { } } - stage('Archive Build Artifacts') { + stage('Archive Artifacts') { when { expression { return (params.ARCHIVE_ARTIFACTS && !params.NOOP) @@ -155,5 +157,34 @@ pipeline { } } + stage('Clean Workspace') { + when { + expression { + return params.CLEAN_BUILD_WORKSPACE + } + } + steps { + deleteDir() /* clean up our workspace */ + } + } + } + +// @TODO Put some notification stuff in here..chatops or whatever + post { + always { + echo 'One way or another, I have finished' + } + success { + echo 'I succeeeded!' + } + unstable { + echo 'I am unstable :/' + } + failure { + echo 'I failed :(' + } + changed { + echo 'Things were different before...' + } } } diff --git a/resources/builders/thinBuildControlDataTest.yaml b/resources/builders/thinBuildControlDataTest.yaml index 813bec02e..b1576a455 100644 --- a/resources/builders/thinBuildControlDataTest.yaml +++ b/resources/builders/thinBuildControlDataTest.yaml @@ -65,9 +65,3 @@ jobGroups: scmUrl : ${PENTAHO_SCM_ROOT}pentaho-data-refinery.git scmBranch : ${DEFAULT_BRANCH} - - jobID : pdi-plugins - scmUrl : ${PENTAHO_SCM_ROOT}pentaho-ee.git - scmBranch : ${DEFAULT_BRANCH} - root : data-integration/plugins - - From 1a820b9f4ac0cfd269dab98dc614ebc86d3199bf Mon Sep 17 00:00:00 2001 From: Larry Grill Date: Sun, 25 Mar 2018 11:15:27 -0400 Subject: [PATCH 4/8] pull my fork libs --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a6479d428..6e69a3748 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -@Library ('jenkins-shared-libraries') _ +@Library ('larrys-jenkins-shared-libraries') _ // We need a global mapped build data object to pass down through the stages of the build def mappedBuildData From 92954fd90874ec41e6ea02c7588279d4694cfa02 Mon Sep 17 00:00:00 2001 From: Larry Grill Date: Sun, 25 Mar 2018 20:16:09 -0400 Subject: [PATCH 5/8] Add timeout and retries --- Jenkinsfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6e69a3748..be12ca5f5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,6 +23,8 @@ pipeline { string(defaultValue: '10', description: 'Maximum parallel source checkout chunk size', name: 'PARALLEL_CHECKOUT_CHUNKSIZE') string(defaultValue: '20', description: 'Shallow clone depth (leave blank for infinite)', name: 'CHECKOUT_DEPTH') + string(defaultValue: '60', description: 'Build timeout in minutes', name: 'BUILD_TIMEOUT') + string(defaultValue: '2', description: 'Build retry count', name: 'BUILD_RETRIES') string(defaultValue: 'http://nexus.pentaho.org/content/groups/omni', description: 'Maven resolve repo global mirror', name: 'MAVEN_RESOLVE_REPO_URL') string(defaultValue: 'github-buildguy', description: 'Use this Jenkins credential for checkouts', @@ -119,8 +121,13 @@ pipeline { return params.RUN_BUILDS } } + failFast true steps { - doBuilds(mappedBuildData) + timeout(time: Integer.valueOf(params.BUILD_TIMEOUT), unit: 'MINUTES') { + retry(Integer.valueOf(params.BUILD_RETRIES)) { + doBuilds(mappedBuildData) + } + } } } @@ -130,8 +137,11 @@ pipeline { return params.RUN_UNIT_TESTS } } + failFast true steps { - doUnitTests(mappedBuildData) + timeout(time: 90, unit: 'MINUTES') { + doUnitTests(mappedBuildData) + } } } From 6a98686c7ad616d68279f21d454ffd189acb0f98 Mon Sep 17 00:00:00 2001 From: Larry Grill Date: Mon, 26 Mar 2018 15:01:29 -0400 Subject: [PATCH 6/8] [CLEANUP] Fix archive unit tests control props --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index be12ca5f5..2c26c4ee7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -148,7 +148,7 @@ pipeline { stage('Archive Test Results') { when { expression { - return (params.ARCHIVE_ARTIFACTS && !params.NOOP) + return (params.RUN_UNIT_TESTS && !params.NOOP) } } steps { From ba18673bff59bd384193f6974680638d5c7c5ce6 Mon Sep 17 00:00:00 2001 From: Larry Grill Date: Mon, 26 Mar 2018 15:39:27 -0400 Subject: [PATCH 7/8] [CLEANUP] add another solo job invocation --- resources/builders/thinBuildControlDataTest.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/builders/thinBuildControlDataTest.yaml b/resources/builders/thinBuildControlDataTest.yaml index b1576a455..b982f765b 100644 --- a/resources/builders/thinBuildControlDataTest.yaml +++ b/resources/builders/thinBuildControlDataTest.yaml @@ -65,3 +65,9 @@ jobGroups: scmUrl : ${PENTAHO_SCM_ROOT}pentaho-data-refinery.git scmBranch : ${DEFAULT_BRANCH} + 4: + - jobID : parent-poms-ee + scmUrl : ${PENTAHO_SCM_ROOT}maven-parent-poms-ee.git + scmBranch : ${DEFAULT_BRANCH} + + From 6e8488b8675dfb76f977940862e5decd7a26ac8a Mon Sep 17 00:00:00 2001 From: Larry Grill Date: Mon, 26 Mar 2018 16:14:27 -0400 Subject: [PATCH 8/8] [CLEANUP] reset shared library name to defauilt --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2c26c4ee7..eb1f21328 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -@Library ('larrys-jenkins-shared-libraries') _ +@Library ('jenkins-shared-libraries') _ // We need a global mapped build data object to pass down through the stages of the build def mappedBuildData