Zack Williams | ce60d71 | 2018-05-27 15:27:57 -0700 | [diff] [blame] | 1 | /* imagebuilder pipeline */ |
| 2 | pipeline { |
| 3 | |
| 4 | /* no label, executor is determined by JJB */ |
| 5 | agent { |
| 6 | label "${params.executorNode}" |
| 7 | } |
| 8 | stages { |
| 9 | |
| 10 | stage('repo') { |
| 11 | steps { |
| 12 | checkout(changelog: false, \ |
| 13 | poll: false, |
| 14 | scm: [$class: 'RepoScm', \ |
| 15 | manifestRepositoryUrl: "${params.manifestUrl}", \ |
| 16 | manifestBranch: "${params.manifestBranch}", \ |
| 17 | currentBranch: true, \ |
| 18 | destinationDir: 'cord', \ |
| 19 | forceSync: true, |
| 20 | resetFirst: true, \ |
| 21 | quiet: true, \ |
| 22 | jobs: 4, \ |
| 23 | showAllChanges: true] \ |
| 24 | ) |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | stage('imagebuilder'){ |
| 29 | steps { |
Zack Williams | 675a755 | 2018-05-29 16:14:09 -0700 | [diff] [blame] | 30 | sh """ |
Zack Williams | ce60d71 | 2018-05-27 15:27:57 -0700 | [diff] [blame] | 31 | #!/usr/bin/env bash |
| 32 | |
Zack Williams | 675a755 | 2018-05-29 16:14:09 -0700 | [diff] [blame] | 33 | mkdir "$WORKSPACE/ib_logs" |
Zack Williams | ce60d71 | 2018-05-27 15:27:57 -0700 | [diff] [blame] | 34 | ib_args="" |
| 35 | |
Zack Williams | 675a755 | 2018-05-29 16:14:09 -0700 | [diff] [blame] | 36 | if [ "${params.force}" = "true" ]; then |
Zack Williams | ce60d71 | 2018-05-27 15:27:57 -0700 | [diff] [blame] | 37 | ib_args+="--force " |
| 38 | fi |
| 39 | |
Zack Williams | 675a755 | 2018-05-29 16:14:09 -0700 | [diff] [blame] | 40 | if [ "${params.build}" = "true" ]; then |
Zack Williams | ce60d71 | 2018-05-27 15:27:57 -0700 | [diff] [blame] | 41 | ib_args+="--build " |
| 42 | fi |
| 43 | |
| 44 | pushd cord/automation-tools/developer |
| 45 | ./imagebuilder.py -vv \${ib_args} -c docker_images.yml \ |
| 46 | -a "$WORKSPACE/ib_actions.yml" \ |
| 47 | -l "$WORKSPACE/ib_logs" \ |
| 48 | -g "$WORKSPACE/ib_graph.dot" |
| 49 | popd |
Zack Williams | 675a755 | 2018-05-29 16:14:09 -0700 | [diff] [blame] | 50 | """ |
Zack Williams | ce60d71 | 2018-05-27 15:27:57 -0700 | [diff] [blame] | 51 | } |
| 52 | } |
| 53 | |
| 54 | stage('push'){ |
| 55 | steps { |
| 56 | script { |
| 57 | def ib_actions = readYaml( file:"$WORKSPACE/ib_actions.yml" ) |
| 58 | |
| 59 | withDockerRegistry([credentialsId: 'docker-artifact-push-credentials']) { |
| 60 | for(image in ib_actions.ib_built){ |
| 61 | for(tag in image.tags){ |
| 62 | push_tag = image.base + ":" + tag |
| 63 | echo "Pushing image: " + push_tag |
| 64 | docker.image(push_tag).push() |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | post { |
| 74 | always { |
| 75 | archiveArtifacts artifacts: 'ib_actions.yml, ib_graph.dot, ib_logs/*', fingerprint: true |
| 76 | deleteDir() |
| 77 | } |
| 78 | } |
| 79 | } |