github.com/simonferquel/app@v0.6.1-0.20181012141724-68b7cccf26ac/Jenkinsfile.baguette (about) 1 properties([buildDiscarder(logRotator(numToKeepStr: '20'))]) 2 3 pipeline { 4 agent { 5 label 'team-local && pipeline' 6 } 7 8 options { 9 skipDefaultCheckout(true) 10 } 11 12 stages { 13 stage('Build') { 14 agent { 15 label 'team-local && linux' 16 } 17 steps { 18 dir('src/github.com/docker/app') { 19 script { 20 try { 21 checkout scm 22 sh 'make -f docker.Makefile lint' 23 sh 'make -f docker.Makefile cross e2e-cross tars' 24 dir('bin') { 25 stash name: 'binaries' 26 } 27 dir('e2e') { 28 stash name: 'e2e' 29 } 30 dir('examples') { 31 stash name: 'examples' 32 } 33 if(!(env.BRANCH_NAME ==~ "PR-\\d+")) { 34 stash name: 'artifacts', includes: 'bin/*.tar.gz', excludes: 'bin/*-e2e-*' 35 archiveArtifacts 'bin/*.tar.gz' 36 } 37 } finally { 38 def clean_images = /docker image ls --format "{{.ID}}\t{{.Tag}}" | grep $(git describe --always --dirty) | awk '{print $1}' | xargs docker image rm -f/ 39 sh clean_images 40 } 41 } 42 } 43 } 44 post { 45 always { 46 deleteDir() 47 } 48 } 49 } 50 stage('Test') { 51 parallel { 52 stage("Coverage") { 53 environment { 54 CODECOV_TOKEN = credentials('jenkins-codecov-token') 55 } 56 agent { 57 label 'team-local && linux' 58 } 59 steps { 60 dir('src/github.com/docker/app') { 61 checkout scm 62 sh 'make -f docker.Makefile coverage' 63 archiveArtifacts '_build/ci-cov/all.out' 64 archiveArtifacts '_build/ci-cov/coverage.html' 65 sh 'curl -s https://codecov.io/bash | bash -s - -f _build/ci-cov/all.out -K' 66 } 67 } 68 } 69 stage("Gradle test") { 70 agent { 71 label 'team-local && linux' 72 } 73 steps { 74 dir('src/github.com/docker/app') { 75 checkout scm 76 dir("bin") { 77 unstash "binaries" 78 } 79 sh 'make -f docker.Makefile gradle-test' 80 } 81 } 82 } 83 stage("Test Linux") { 84 agent { 85 label 'team-local && linux' 86 } 87 environment { 88 DOCKERAPP_BINARY = '../docker-app-linux' 89 } 90 steps { 91 dir('src/github.com/docker/app') { 92 unstash "binaries" 93 dir('examples') { 94 unstash "examples" 95 } 96 dir('e2e'){ 97 unstash "e2e" 98 } 99 sh './docker-app-e2e-linux --e2e-path=e2e' 100 } 101 } 102 post { 103 always { 104 deleteDir() 105 } 106 } 107 } 108 stage("Test Mac") { 109 agent { 110 label 'team-local && mac' 111 } 112 environment { 113 DOCKERAPP_BINARY = '../docker-app-darwin' 114 } 115 steps { 116 dir('src/github.com/docker/app') { 117 unstash "binaries" 118 dir('examples') { 119 unstash "examples" 120 } 121 dir('e2e'){ 122 unstash "e2e" 123 } 124 sh './docker-app-e2e-darwin --e2e-path=e2e' 125 } 126 } 127 post { 128 always { 129 deleteDir() 130 } 131 } 132 } 133 stage("Test Win") { 134 agent { 135 label 'team-local && windows && linux-containers' 136 } 137 environment { 138 DOCKERAPP_BINARY = '../docker-app-windows.exe' 139 } 140 steps { 141 dir('src/github.com/docker/app') { 142 unstash "binaries" 143 dir('examples') { 144 unstash "examples" 145 } 146 dir('e2e'){ 147 unstash "e2e" 148 } 149 bat 'docker-app-e2e-windows.exe --e2e-path=e2e' 150 } 151 } 152 post { 153 always { 154 deleteDir() 155 } 156 } 157 } 158 } 159 } 160 stage('Release') { 161 agent { 162 label 'team-local && linux' 163 } 164 when { 165 buildingTag() 166 } 167 steps { 168 dir('src/github.com/docker/app') { 169 unstash 'artifacts' 170 echo "Releasing $TAG_NAME" 171 dir('bin') { 172 release('docker/app') 173 } 174 } 175 } 176 post { 177 always { 178 deleteDir() 179 } 180 } 181 } 182 } 183 } 184 185 def release(repo) { 186 withCredentials([[$class: 'StringBinding', credentialsId: 'github-release-token', variable: 'GITHUB_TOKEN']]) { 187 def data = "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\", \"draft\": true, \"prerelease\": true}" 188 def url = "https://api.github.com/repos/$repo/releases" 189 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") 190 def release = readJSON text: reply 191 url = release.upload_url.replace('{?name,label}', '') 192 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") 193 } 194 }