blob: 7af9a53d5c140a7860fd2398507daac3aa55114e [file] [log] [blame]
Andy Bavierc5178522018-12-12 15:36:30 -07001/* voltha-publish pipeline */
2pipeline {
3
4 /* no label, executor is determined by JJB */
5 agent {
Zack Williamsb3292082019-10-11 17:15:18 -07006 label "${params.buildNode}"
Andy Bavierc5178522018-12-12 15:36:30 -07007 }
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}", \
Andy Bavierda0d6ba2018-12-13 13:06:37 -070017 manifestGroup: 'voltha', \
Andy Bavierc5178522018-12-12 15:36:30 -070018 currentBranch: true, \
19 destinationDir: 'cord', \
Andy Bavierf88fa092019-07-01 14:51:49 -070020 forceSync: true, \
Andy Bavierc5178522018-12-12 15:36:30 -070021 resetFirst: true, \
22 quiet: true, \
23 jobs: 4, \
24 showAllChanges: true] \
25 )
26 }
27 }
28
29 stage('build'){
30 steps {
31 sh """
Andy Bavier3fd92f02019-07-01 11:39:58 -070032 #!/usr/bin/env bash
Andy Bavierc5178522018-12-12 15:36:30 -070033
Andy Bavier3fd92f02019-07-01 11:39:58 -070034 pushd cord/incubator/voltha
35 if [ "${params.manifestBranch}" == "master" ]
36 then
Andy Bavierf88fa092019-07-01 14:51:49 -070037 TAG="latest"
Andy Bavier3fd92f02019-07-01 11:39:58 -070038 else
Andy Bavierf88fa092019-07-01 14:51:49 -070039 TAG="${params.manifestBranch}"
Andy Bavier3fd92f02019-07-01 11:39:58 -070040 fi
Andy Bavierf88fa092019-07-01 14:51:49 -070041 VOLTHA_BUILD=docker DOCKER_CACHE_ARG=--no-cache TAG=\$TAG make build
Andy Bavier3fd92f02019-07-01 11:39:58 -070042 popd
43 """
Andy Bavierc5178522018-12-12 15:36:30 -070044 }
45 }
46
47 stage('push'){
48 steps {
49 withDockerRegistry([credentialsId: 'docker-artifact-push-credentials', url: '']) {
50 sh """
51 #!/usr/bin/env bash
52
53 pushd cord/incubator/voltha
Andy Bavier3fd92f02019-07-01 11:39:58 -070054 if [ "${params.manifestBranch}" == "master" ]
Andy Bavierf159a202019-03-21 16:01:24 -070055 then
Andy Bavierf88fa092019-07-01 14:51:49 -070056 TAG="latest"
Andy Bavierf159a202019-03-21 16:01:24 -070057 else
Andy Bavierf88fa092019-07-01 14:51:49 -070058 TAG="${params.manifestBranch}"
Andy Bavier3fd92f02019-07-01 11:39:58 -070059 fi
60
Andy Bavier46c6e192019-07-09 08:05:48 -070061 # Check for SemVer in VERSION (only numbers and dots)
62 RELEASETAG=\$(cat voltha/VERSION|tr -d ' '|egrep '^[0-9]+(\\.[0-9]+)*\$'||true)
Andy Bavier5e50f152019-07-02 16:36:04 -070063 if [ "\$RELEASETAG" != "" ]
Andy Bavier3fd92f02019-07-01 11:39:58 -070064 then
Andy Bavier5e50f152019-07-02 16:36:04 -070065 VOLTHA_BUILD=docker TAG=\$TAG TARGET_REPOSITORY=voltha/ TARGET_TAG=\$RELEASETAG make push
Andy Bavier3fd92f02019-07-01 11:39:58 -070066 else
Andy Bavierf88fa092019-07-01 14:51:49 -070067 VOLTHA_BUILD=docker TAG=\$TAG TARGET_REPOSITORY=voltha/ TARGET_TAG=\$TAG make push
Andy Bavierf159a202019-03-21 16:01:24 -070068 fi
Andy Bavierc5178522018-12-12 15:36:30 -070069 popd
70 """
71 }
72 }
73 }
74 }
75
76 post {
77 failure {
78 emailext (
79 subject: "$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS",
80 body: "Check console output at $BUILD_URL to view the results.",
81 to: "${params.failureEmail}"
82 )
83 }
84 }
85}