310 строки
14 KiB
Plaintext
310 строки
14 KiB
Plaintext
properties([buildDiscarder(logRotator(numToKeepStr: '20'))])
|
|
|
|
pipeline {
|
|
agent {
|
|
label 'ubuntu-1804'
|
|
}
|
|
|
|
options {
|
|
skipDefaultCheckout(true)
|
|
}
|
|
|
|
environment {
|
|
TAG = tag()
|
|
BUILD_TAG = tag()
|
|
DOCKER_BUILDKIT = "1"
|
|
}
|
|
|
|
stages {
|
|
stage('Build') {
|
|
parallel {
|
|
stage('Binaries'){
|
|
agent {
|
|
label 'ubuntu-1804'
|
|
}
|
|
steps {
|
|
dir('src/github.com/docker/app') {
|
|
script {
|
|
try {
|
|
checkout scm
|
|
ansiColor('xterm') {
|
|
sh 'make -f docker.Makefile lint'
|
|
sh 'make -f docker.Makefile cli-cross cross e2e-cross tars'
|
|
}
|
|
dir('bin') {
|
|
stash name: 'binaries'
|
|
}
|
|
dir('e2e') {
|
|
stash name: 'e2e'
|
|
}
|
|
dir('examples') {
|
|
stash name: 'examples'
|
|
}
|
|
if(!(env.BRANCH_NAME ==~ "PR-\\d+")) {
|
|
stash name: 'artifacts', includes: 'bin/*.tar.gz', excludes: 'bin/*-e2e-*'
|
|
}
|
|
archiveArtifacts 'bin/*.tar.gz'
|
|
} finally {
|
|
def clean_images = /docker image ls --format="{{.Repository}}:{{.Tag}}" '*$TAG*' | xargs --no-run-if-empty docker image rm -f/
|
|
sh clean_images
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
deleteDir()
|
|
}
|
|
}
|
|
}
|
|
stage('Invocation image'){
|
|
agent {
|
|
label 'team-local && windows && linux-containers'
|
|
}
|
|
steps {
|
|
dir('src/github.com/docker/app') {
|
|
checkout scm
|
|
ansiColor('xterm') {
|
|
sh 'make -f docker.Makefile invocation-image-cross save-invocation-image-cross'
|
|
sh 'make -f docker.Makefile save-invocation-image-tag INVOCATION_IMAGE_TAG=$TAG-coverage OUTPUT=coverage-invocation-image.tar'
|
|
}
|
|
dir('_build') {
|
|
stash name: 'invocation-image', includes: 'invocation-image.tar'
|
|
stash name: 'invocation-image-arm64', includes: 'invocation-image-arm64.tar'
|
|
stash name: 'invocation-image-arm', includes: 'invocation-image-arm.tar'
|
|
stash name: 'coverage-invocation-image', includes: 'coverage-invocation-image.tar'
|
|
archiveArtifacts 'invocation-image*.tar'
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
sh 'docker rmi docker/cnab-app-base:$TAG'
|
|
sh 'docker rmi docker/cnab-app-base:$TAG-arm64'
|
|
sh 'docker rmi docker/cnab-app-base:$TAG-arm'
|
|
sh 'docker rmi docker/cnab-app-base:$TAG-coverage'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Test') {
|
|
parallel {
|
|
stage("Coverage") {
|
|
environment {
|
|
DOCKERAPP_BINARY = '../e2e/coverage-bin'
|
|
DOCKERCLI_BINARY = '../docker-linux'
|
|
CODECOV_TOKEN = credentials('jenkins-codecov-token')
|
|
}
|
|
agent {
|
|
label 'ubuntu-1804'
|
|
}
|
|
steps {
|
|
dir('src/github.com/docker/app') {
|
|
checkout scm
|
|
dir('_build') {
|
|
unstash "coverage-invocation-image"
|
|
sh 'docker load -i coverage-invocation-image.tar'
|
|
}
|
|
ansiColor('xterm') {
|
|
sh 'make -f docker.Makefile TAG=$TAG-coverage coverage-run'
|
|
sh 'make -f docker.Makefile TAG=$TAG-coverage coverage-results'
|
|
}
|
|
archiveArtifacts '_build/ci-cov/all.out'
|
|
archiveArtifacts '_build/ci-cov/coverage.html'
|
|
sh 'curl -s https://codecov.io/bash | bash -s - -f _build/ci-cov/all.out -K'
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
dir('src/github.com/docker/app/_build/test-results') {
|
|
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'
|
|
sh '[ ! -e e2e-coverage.xml ] || sed -i -E -e \'s,"github.com/docker/app/e2e","e2e/coverage",g\' e2e-coverage.xml'
|
|
archiveArtifacts '*.xml'
|
|
junit '*.xml'
|
|
}
|
|
sh 'docker rmi docker/cnab-app-base:$TAG-coverage'
|
|
deleteDir()
|
|
}
|
|
}
|
|
}
|
|
stage("Test Linux") {
|
|
agent {
|
|
label 'ubuntu-1804'
|
|
}
|
|
environment {
|
|
DOCKERAPP_BINARY = '../docker-app-linux'
|
|
DOCKERCLI_BINARY = '../docker-linux'
|
|
}
|
|
steps {
|
|
dir('src/github.com/docker/app') {
|
|
checkout scm
|
|
dir('_build') {
|
|
unstash "invocation-image"
|
|
sh 'docker load -i invocation-image.tar'
|
|
}
|
|
unstash "binaries"
|
|
dir('examples') {
|
|
unstash "examples"
|
|
}
|
|
dir('e2e'){
|
|
unstash "e2e"
|
|
}
|
|
sh './docker-linux version'
|
|
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'
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
archiveArtifacts 'src/github.com/docker/app/e2e-linux.xml'
|
|
junit 'src/github.com/docker/app/e2e-linux.xml'
|
|
sh 'docker rmi docker/cnab-app-base:$TAG'
|
|
deleteDir()
|
|
}
|
|
}
|
|
}
|
|
stage("Test Mac") {
|
|
agent {
|
|
label 'team-local && mac'
|
|
}
|
|
environment {
|
|
DOCKERAPP_BINARY = '../docker-app-darwin'
|
|
DOCKERCLI_BINARY = '../docker-darwin'
|
|
}
|
|
steps {
|
|
dir('src/github.com/docker/app') {
|
|
checkout scm
|
|
dir('_build') {
|
|
unstash "invocation-image"
|
|
sh 'docker load -i invocation-image.tar'
|
|
}
|
|
unstash "binaries"
|
|
dir('examples') {
|
|
unstash "examples"
|
|
}
|
|
dir('e2e'){
|
|
unstash "e2e"
|
|
}
|
|
sh './docker-darwin version'
|
|
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'
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
archiveArtifacts 'src/github.com/docker/app/e2e-darwin.xml'
|
|
junit 'src/github.com/docker/app/e2e-darwin.xml'
|
|
sh 'docker rmi docker/cnab-app-base:$TAG'
|
|
deleteDir()
|
|
}
|
|
}
|
|
}
|
|
stage("Test Win") {
|
|
agent {
|
|
label 'team-local && windows && linux-containers'
|
|
}
|
|
environment {
|
|
DOCKERAPP_BINARY = '../docker-app-windows.exe'
|
|
DOCKERCLI_BINARY = '../docker-windows.exe'
|
|
}
|
|
steps {
|
|
dir('src/github.com/docker/app') {
|
|
checkout scm
|
|
unstash "binaries"
|
|
sh './docker-windows.exe version'
|
|
dir('_build') {
|
|
unstash "invocation-image"
|
|
bat 'docker load -i invocation-image.tar'
|
|
}
|
|
dir('examples') {
|
|
unstash "examples"
|
|
}
|
|
dir('e2e'){
|
|
unstash "e2e"
|
|
}
|
|
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'
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
archiveArtifacts 'src/github.com/docker/app/e2e-windows.xml'
|
|
junit 'src/github.com/docker/app/e2e-windows.xml'
|
|
bat 'docker rmi docker/cnab-app-base:%TAG%'
|
|
deleteDir()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Release') {
|
|
when {
|
|
buildingTag()
|
|
}
|
|
agent {
|
|
label 'ubuntu-1804'
|
|
}
|
|
environment {
|
|
DOCKERHUB_CREDS=credentials('dockerhub-dockerdsgcibot')
|
|
}
|
|
steps{
|
|
echo "Pushing Base Invocation Image"
|
|
sh 'echo "${DOCKERHUB_CREDS_PSW}" | docker login --username "${DOCKERHUB_CREDS_USR}" --password-stdin'
|
|
dir('src/github.com/docker/app') {
|
|
checkout scm
|
|
dir('_build') {
|
|
unstash "invocation-image"
|
|
sh 'docker load -i invocation-image.tar'
|
|
unstash "invocation-image-arm64"
|
|
sh 'docker load -i invocation-image-arm64.tar'
|
|
unstash "invocation-image-arm"
|
|
sh 'docker load -i invocation-image-arm.tar'
|
|
}
|
|
ansiColor('xterm') {
|
|
sh 'make -f docker.Makefile push-invocation-image'
|
|
}
|
|
}
|
|
unstash 'artifacts'
|
|
echo "Releasing $TAG_NAME"
|
|
dir('bin') {
|
|
release('docker/app')
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
sh 'docker rmi docker/cnab-app-base:$TAG'
|
|
sh 'docker rmi docker/cnab-app-base:$TAG-arm64'
|
|
sh 'docker rmi docker/cnab-app-base:$TAG-arm'
|
|
deleteDir()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
failure {
|
|
script {
|
|
if (env.BRANCH_NAME == 'master') {
|
|
slackSend channel: '#app-def-team', color: 'danger',
|
|
message: "Build #${env.BUILD_NUMBER} failed: ${env.BUILD_URL}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def release(repo) {
|
|
withCredentials([[$class: 'StringBinding', credentialsId: 'github-release-token', variable: 'GITHUB_TOKEN']]) {
|
|
def data = "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\", \"draft\": true, \"prerelease\": true}"
|
|
def url = "https://api.github.com/repos/$repo/releases"
|
|
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")
|
|
def release = readJSON text: reply
|
|
url = release.upload_url.replace('{?name,label}', '')
|
|
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")
|
|
}
|
|
}
|
|
|
|
def tag() {
|
|
if (env.TAG_NAME != null) {
|
|
return env.TAG_NAME
|
|
} else {
|
|
return env.BUILD_TAG
|
|
}
|
|
} |