blob: 1d5a950fd2f2c4da7bf1b8b4159a6c8135dc3d69 [file] [log] [blame]
Zack Williamsce60d712018-05-27 15:27:57 -07001/* imagebuilder pipeline */
2pipeline {
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 Williams675a7552018-05-29 16:14:09 -070030 sh """
Zack Williamsce60d712018-05-27 15:27:57 -070031 #!/usr/bin/env bash
32
Zack Williams675a7552018-05-29 16:14:09 -070033 mkdir "$WORKSPACE/ib_logs"
Zack Williamsce60d712018-05-27 15:27:57 -070034 ib_args=""
35
Zack Williams675a7552018-05-29 16:14:09 -070036 if [ "${params.force}" = "true" ]; then
Zack Williamsce60d712018-05-27 15:27:57 -070037 ib_args+="--force "
38 fi
39
Zack Williams675a7552018-05-29 16:14:09 -070040 if [ "${params.build}" = "true" ]; then
Zack Williamsce60d712018-05-27 15:27:57 -070041 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 Williams675a7552018-05-29 16:14:09 -070050 """
Zack Williamsce60d712018-05-27 15:27:57 -070051 }
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 }
Zack Williams5e09c952018-06-12 10:19:48 -070078 failure {
79 emailext (
Zack Williams3e112f42018-06-12 15:18:25 -070080 subject: "$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS",
81 body: "Check console output at $BUILD_URL to view the results.",
Zack Williams5e09c952018-06-12 10:19:48 -070082 to: "${params.failureEmail}"
83 )
84 }
Zack Williamsce60d712018-05-27 15:27:57 -070085 }
86}