From 1a11cb76bd3670486a7150ca5202f5f3e03cbc6a Mon Sep 17 00:00:00 2001 From: Per Goncalves da Silva Date: Thu, 19 Sep 2019 21:34:21 +0200 Subject: [PATCH] Adds release job update to CD pipeline --- cd/Jenkinsfile_cd_pipeline | 3 +++ cd/Jenkinsfile_release_job | 25 +++++++++++++++++-------- cd/Jenkinsfile_utils.groovy | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/cd/Jenkinsfile_cd_pipeline b/cd/Jenkinsfile_cd_pipeline index 4e4e6a7af3d4..885df7fa47a3 100644 --- a/cd/Jenkinsfile_cd_pipeline +++ b/cd/Jenkinsfile_cd_pipeline @@ -39,6 +39,9 @@ pipeline { steps { script { cd_utils = load('cd/Jenkinsfile_utils.groovy') + + // Update release job state in Jenkins + cd_utils.update_release_job_state() } } } diff --git a/cd/Jenkinsfile_release_job b/cd/Jenkinsfile_release_job index f1be0633b78d..c2be26124029 100644 --- a/cd/Jenkinsfile_release_job +++ b/cd/Jenkinsfile_release_job @@ -50,7 +50,7 @@ pipeline { stages { stage("Init") { steps { - script{ + script { cd_utils = load('cd/Jenkinsfile_utils.groovy') ci_utils = load('ci/Jenkinsfile_utils.groovy') ci_utils.assign_node_labels( @@ -62,19 +62,31 @@ pipeline { windows_gpu: 'restricted-mxnetwindows-gpu' ) - echo """\ + // Skip Jenkins state update jobs + if (env.RELEASE_JOB_TYPE == cd_utils.STATE_UPDATE) { + echo """\ + |Job Type: ${env.RELEASE_JOB_TYPE} + |Commit Id: ${env.GIT_COMMIT}""".stripMargin() + } else { + echo """\ |Job Name: ${env.RELEASE_JOB_NAME} |Job Type: ${env.RELEASE_JOB_TYPE} |Release Build: ${params.RELEASE_BUILD} |Commit Id: ${env.GIT_COMMIT} |Branch: ${env.GIT_BRANCH} |Variants: ${env.MXNET_VARIANTS}""".stripMargin() + } } } } stage("Release Job") { steps { script { + // Skip builds for state update job + if (env.RELEASE_JOB_TYPE == cd_utils.STATE_UPDATE) { + currentBuild.result = "SUCCESS" + return + } // Add new job types here def valid_job_types = [ @@ -88,17 +100,14 @@ pipeline { list << item.trim() }.findAll { item -> ! (item == null || item.isEmpty()) } - echo "size: ${mxnet_variants.size()}" - // Exit successfully if there are no variants to build if (mxnet_variants.size() == 0) { - currentBuild.result = 'SUCCESS' - return + error "No variants to build..." } // Only execute from allowed release job types - if (! ("${params.RELEASE_JOB_TYPE}" in valid_job_types)) { - error "Unknown release job type ${params.RELEASE_JOB_TYPE}" + if (! (valid_job_types.contains(params.RELEASE_JOB_TYPE))) { + error "Unknown release job type '${params.RELEASE_JOB_TYPE}'" } // Load script for the supplied job type diff --git a/cd/Jenkinsfile_utils.groovy b/cd/Jenkinsfile_utils.groovy index c4647b2fe8d0..da17c19b562c 100644 --- a/cd/Jenkinsfile_utils.groovy +++ b/cd/Jenkinsfile_utils.groovy @@ -23,6 +23,9 @@ // 'Jenkins_pipeline.groovy' file and has the pipeline definition for the // artifact (docker image, binary, pypi or maven package, etc.) that should // be published. + +STATE_UPDATE="State Update" + def trigger_release_job(job_name, job_type, mxnet_variants) { def run = build( job: env.CD_RELEASE_JOB_NAME, @@ -56,6 +59,23 @@ def trigger_release_job(job_name, job_type, mxnet_variants) { } } + +// This triggers a downstream release job with no +// variants and not job type. This will update +// the configuration of the release job in jenkins +// to the configuration of release job as defined in the +// Jenkinsfile _release_job for env.GIT_COMMIT revision +def update_release_job_state() { + build( + job: env.CD_RELEASE_JOB_NAME, + parameters: [ + string(name: "RELEASE_JOB_TYPE", value: STATE_UPDATE), + + // Should be set to the current git commit + string(name: "COMMIT_ID", value: "${env.GIT_COMMIT}") + ]) +} + // Wraps variant pipeline with error catching and // job status setting code // If there's an error in one of the pipelines, set status to UNSTABLE