Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Adds release job update to CD pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
perdasilva committed Sep 19, 2019
1 parent 0cc4c6f commit 715d1e3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
3 changes: 3 additions & 0 deletions cd/Jenkinsfile_cd_pipeline
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
Expand Down
24 changes: 16 additions & 8 deletions cd/Jenkinsfile_release_job
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -62,13 +62,24 @@ 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()

currentBuild.result = "SUCCESS"
return
} 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}
|State Update: ${cd_utils.STATE_UPDATE}
|Variants: ${env.MXNET_VARIANTS}""".stripMargin()
}
}
}
}
Expand All @@ -88,17 +99,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
Expand Down
20 changes: 20 additions & 0 deletions cd/Jenkinsfile_utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 715d1e3

Please sign in to comment.