github.com/docker/app@v0.9.1-beta3.0.20210611140623-a48f773ab002/Jenkinsfile.baguette (about) 1 properties([buildDiscarder(logRotator(numToKeepStr: '20'))]) 2 3 pipeline { 4 agent { 5 label 'ubuntu-1804' 6 } 7 8 options { 9 skipDefaultCheckout(true) 10 } 11 12 environment { 13 TAG = tag() 14 BUILD_TAG = tag() 15 DOCKER_BUILDKIT = "1" 16 } 17 18 stages { 19 stage('Build') { 20 parallel { 21 stage('Binaries'){ 22 agent { 23 label 'ubuntu-1804' 24 } 25 steps { 26 dir('src/github.com/docker/app') { 27 script { 28 try { 29 checkout scm 30 ansiColor('xterm') { 31 sh 'make -f docker.Makefile lint' 32 sh 'make -f docker.Makefile cli-cross cross e2e-cross tars' 33 } 34 dir('bin') { 35 stash name: 'binaries' 36 } 37 dir('e2e') { 38 stash name: 'e2e' 39 } 40 dir('examples') { 41 stash name: 'examples' 42 } 43 if(!(env.BRANCH_NAME ==~ "PR-\\d+")) { 44 stash name: 'artifacts', includes: 'bin/*.tar.gz', excludes: 'bin/*-e2e-*' 45 } 46 archiveArtifacts 'bin/*.tar.gz' 47 } finally { 48 def clean_images = /docker image ls --format="{{.Repository}}:{{.Tag}}" '*$TAG*' | xargs --no-run-if-empty docker image rm -f/ 49 sh clean_images 50 } 51 } 52 } 53 } 54 post { 55 always { 56 deleteDir() 57 } 58 } 59 } 60 stage('Invocation image'){ 61 agent { 62 label 'team-local && windows && linux-containers' 63 } 64 steps { 65 dir('src/github.com/docker/app') { 66 checkout scm 67 ansiColor('xterm') { 68 sh 'make -f docker.Makefile invocation-image-cross save-invocation-image-cross' 69 sh 'make -f docker.Makefile save-invocation-image-tag INVOCATION_IMAGE_TAG=$TAG-coverage OUTPUT=coverage-invocation-image.tar' 70 } 71 dir('_build') { 72 stash name: 'invocation-image', includes: 'invocation-image.tar' 73 stash name: 'invocation-image-arm64', includes: 'invocation-image-arm64.tar' 74 stash name: 'invocation-image-arm', includes: 'invocation-image-arm.tar' 75 stash name: 'coverage-invocation-image', includes: 'coverage-invocation-image.tar' 76 archiveArtifacts 'invocation-image*.tar' 77 } 78 } 79 } 80 post { 81 always { 82 sh 'docker rmi docker/cnab-app-base:$TAG' 83 sh 'docker rmi docker/cnab-app-base:$TAG-arm64' 84 sh 'docker rmi docker/cnab-app-base:$TAG-arm' 85 sh 'docker rmi docker/cnab-app-base:$TAG-coverage' 86 } 87 } 88 } 89 } 90 } 91 stage('Test') { 92 parallel { 93 stage("Coverage") { 94 environment { 95 DOCKERAPP_BINARY = '../e2e/coverage-bin' 96 DOCKERCLI_BINARY = '../docker-linux' 97 CODECOV_TOKEN = credentials('jenkins-codecov-token') 98 } 99 agent { 100 label 'ubuntu-1804' 101 } 102 steps { 103 dir('src/github.com/docker/app') { 104 checkout scm 105 dir('_build') { 106 unstash "coverage-invocation-image" 107 sh 'docker load -i coverage-invocation-image.tar' 108 } 109 ansiColor('xterm') { 110 sh 'make -f docker.Makefile TAG=$TAG-coverage coverage-run' 111 sh 'make -f docker.Makefile TAG=$TAG-coverage coverage-results' 112 } 113 archiveArtifacts '_build/ci-cov/all.out' 114 archiveArtifacts '_build/ci-cov/coverage.html' 115 sh 'curl -s https://codecov.io/bash | bash -s - -f _build/ci-cov/all.out -K' 116 } 117 } 118 post { 119 always { 120 dir('src/github.com/docker/app/_build/test-results') { 121 sh '[ ! -e unit-coverage.xml ] || sed -i -E -e \'s,"github.com/docker/app","unit",g; s,"github.com/docker/app/([^"]*)","unit/\\1",g\' unit-coverage.xml' 122 sh '[ ! -e e2e-coverage.xml ] || sed -i -E -e \'s,"github.com/docker/app/e2e","e2e/coverage",g\' e2e-coverage.xml' 123 archiveArtifacts '*.xml' 124 junit '*.xml' 125 } 126 sh 'docker rmi docker/cnab-app-base:$TAG-coverage' 127 deleteDir() 128 } 129 } 130 } 131 stage("Test Linux") { 132 agent { 133 label 'ubuntu-1804' 134 } 135 environment { 136 DOCKERAPP_BINARY = '../docker-app-linux' 137 DOCKERCLI_BINARY = '../docker-linux' 138 } 139 steps { 140 dir('src/github.com/docker/app') { 141 checkout scm 142 dir('_build') { 143 unstash "invocation-image" 144 sh 'docker load -i invocation-image.tar' 145 } 146 unstash "binaries" 147 dir('examples') { 148 unstash "examples" 149 } 150 dir('e2e'){ 151 unstash "e2e" 152 } 153 sh './docker-linux version' 154 sh './gotestsum-linux --format short-verbose --junitfile e2e-linux.xml --raw-command -- ./test2json-linux -t -p e2e/linux ./docker-app-e2e-linux -test.v --e2e-path=e2e' 155 } 156 } 157 post { 158 always { 159 archiveArtifacts 'src/github.com/docker/app/e2e-linux.xml' 160 junit 'src/github.com/docker/app/e2e-linux.xml' 161 sh 'docker rmi docker/cnab-app-base:$TAG' 162 deleteDir() 163 } 164 } 165 } 166 stage("Test Mac") { 167 agent { 168 label 'team-local && mac' 169 } 170 environment { 171 DOCKERAPP_BINARY = '../docker-app-darwin' 172 DOCKERCLI_BINARY = '../docker-darwin' 173 } 174 steps { 175 dir('src/github.com/docker/app') { 176 checkout scm 177 dir('_build') { 178 unstash "invocation-image" 179 sh 'docker load -i invocation-image.tar' 180 } 181 unstash "binaries" 182 dir('examples') { 183 unstash "examples" 184 } 185 dir('e2e'){ 186 unstash "e2e" 187 } 188 sh './docker-darwin version' 189 sh './gotestsum-darwin --format short-verbose --junitfile e2e-darwin.xml --raw-command -- ./test2json-darwin -t -p e2e/darwin ./docker-app-e2e-darwin -test.v --e2e-path=e2e' 190 } 191 } 192 post { 193 always { 194 archiveArtifacts 'src/github.com/docker/app/e2e-darwin.xml' 195 junit 'src/github.com/docker/app/e2e-darwin.xml' 196 sh 'docker rmi docker/cnab-app-base:$TAG' 197 deleteDir() 198 } 199 } 200 } 201 stage("Test Win") { 202 agent { 203 label 'team-local && windows && linux-containers' 204 } 205 environment { 206 DOCKERAPP_BINARY = '../docker-app-windows.exe' 207 DOCKERCLI_BINARY = '../docker-windows.exe' 208 } 209 steps { 210 dir('src/github.com/docker/app') { 211 checkout scm 212 unstash "binaries" 213 sh './docker-windows.exe version' 214 dir('_build') { 215 unstash "invocation-image" 216 bat 'docker load -i invocation-image.tar' 217 } 218 dir('examples') { 219 unstash "examples" 220 } 221 dir('e2e'){ 222 unstash "e2e" 223 } 224 bat 'gotestsum-windows.exe --format short-verbose --junitfile e2e-windows.xml --raw-command -- test2json-windows.exe -t -p e2e/windows docker-app-e2e-windows.exe -test.v --e2e-path=e2e' 225 } 226 } 227 post { 228 always { 229 archiveArtifacts 'src/github.com/docker/app/e2e-windows.xml' 230 junit 'src/github.com/docker/app/e2e-windows.xml' 231 bat 'docker rmi docker/cnab-app-base:%TAG%' 232 deleteDir() 233 } 234 } 235 } 236 } 237 } 238 stage('Release') { 239 when { 240 buildingTag() 241 } 242 agent { 243 label 'ubuntu-1804' 244 } 245 environment { 246 DOCKERHUB_CREDS=credentials('dockerhub-dockerdsgcibot') 247 } 248 steps{ 249 echo "Pushing Base Invocation Image" 250 sh 'echo "${DOCKERHUB_CREDS_PSW}" | docker login --username "${DOCKERHUB_CREDS_USR}" --password-stdin' 251 dir('src/github.com/docker/app') { 252 checkout scm 253 dir('_build') { 254 unstash "invocation-image" 255 sh 'docker load -i invocation-image.tar' 256 unstash "invocation-image-arm64" 257 sh 'docker load -i invocation-image-arm64.tar' 258 unstash "invocation-image-arm" 259 sh 'docker load -i invocation-image-arm.tar' 260 } 261 ansiColor('xterm') { 262 sh 'make -f docker.Makefile push-invocation-image' 263 } 264 } 265 unstash 'artifacts' 266 echo "Releasing $TAG_NAME" 267 dir('bin') { 268 release('docker/app') 269 } 270 } 271 post { 272 always { 273 sh 'docker rmi docker/cnab-app-base:$TAG' 274 sh 'docker rmi docker/cnab-app-base:$TAG-arm64' 275 sh 'docker rmi docker/cnab-app-base:$TAG-arm' 276 deleteDir() 277 } 278 } 279 } 280 } 281 post { 282 failure { 283 script { 284 if (env.BRANCH_NAME == 'master') { 285 slackSend channel: '#app-def-team', color: 'danger', 286 message: "Build #${env.BUILD_NUMBER} failed: ${env.BUILD_URL}" 287 } 288 } 289 } 290 } 291 } 292 293 def release(repo) { 294 withCredentials([[$class: 'StringBinding', credentialsId: 'github-release-token', variable: 'GITHUB_TOKEN']]) { 295 def data = "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\", \"draft\": true, \"prerelease\": true}" 296 def url = "https://api.github.com/repos/$repo/releases" 297 def reply = sh(returnStdout: true, script: "curl -sSf -H \"Authorization: token $GITHUB_TOKEN\" -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d '$data' $url") 298 def release = readJSON text: reply 299 url = release.upload_url.replace('{?name,label}', '') 300 sh("for f in * ; do curl -sf -H \"Authorization: token $GITHUB_TOKEN\" -H \"Accept: application/json\" -H \"Content-type: application/octet-stream\" -X POST --data-binary \"@\${f}\" $url?name=\${f}; done") 301 } 302 } 303 304 def tag() { 305 if (env.TAG_NAME != null) { 306 return env.TAG_NAME 307 } else { 308 return env.BUILD_TAG 309 } 310 }