From 2dc6274cfda286bbab8dc8238beeaaa32e190893 Mon Sep 17 00:00:00 2001 From: George Adams Date: Tue, 18 May 2021 12:58:10 +0100 Subject: [PATCH] docker: add jenkinsfile to build images (#2187) * docker: add jenkinsfile to build images * Update Jenkinsfile * Update Jenkinsfile * Update Jenkinsfile --- .travis.yml | 36 --------------------------- Jenkinsfile | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 36 deletions(-) delete mode 100644 .travis.yml create mode 100644 Jenkinsfile diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9a106fa960..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -arch: - - amd64 - - arm64-graviton2 - - ppc64le - -env: - - TARGET="adoptopenjdk/centos7_build_image" - -os: - - linux - -dist: bionic - -virt: lxd -group: edge -install: skip - -script: - - docker build -t $TARGET:$TRAVIS_OS_NAME-$TRAVIS_CPU_ARCH -f ansible/Dockerfile.CentOS7 . -after_success: - - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin; docker push $TARGET:$TRAVIS_OS_NAME-$TRAVIS_CPU_ARCH; fi - -jobs: - include: - - stage: manifest - script: export DOCKER_CLI_EXPERIMENTAL=enabled && - AMD64=$TARGET:linux-amd64 && - ARM64=$TARGET:linux-arm64 && - PPC64LE=$TARGET:linux-ppc64le && - docker manifest create adoptopenjdk/centos7_build_image $AMD64 $ARM64 $PPC64LE && - docker manifest annotate $TARGET $AMD64 --arch amd64 --os linux && - docker manifest annotate $TARGET $ARM64 --arch arm64 --os linux && - docker manifest annotate $TARGET $PPC64LE --arch ppc64le --os linux - after_success: - - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin; docker manifest push $TARGET; fi diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..33c249b442 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,71 @@ +pipeline { + agent none + stages { + stage('Docker Build') { + parallel { + stage('Linux x64') { + agent { + label "dockerBuild&&linux&&x64" + } + steps { + dockerBuild('amd64') + } + } + stage('Linux aarch64') { + agent { + label "dockerBuild&&linux&&aarch64" + } + steps { + dockerBuild('arm64') + } + } + stage('Linux ppc64le') { + agent { + label "dockerBuild&&linux&&ppc64le" + } + steps { + dockerBuild('ppc64le') + } + } + } + } + stage('Docker Manifest') { + agent { + label "dockerBuild&&linux&&x64" + } + environment { + DOCKER_CLI_EXPERIMENTAL = "enabled" + } + steps { + dockerManifest() + } + } + } +} + +def dockerBuild(architecture) { + git poll: false, url: 'https://github.com/adoptium/infrastructure.git' + sh label: '', script: "docker build -t adoptopenjdk/centos7_build_image:linux-$architecture -f ansible/Dockerfile.CentOS7 ." + // dockerhub is the ID of the credentials stored in Jenkins + docker.withRegistry('https://index.docker.io/v1/', 'dockerhub') { + sh label: '', script: "docker push adoptopenjdk/centos7_build_image:linux-$architecture" + } +} + +def dockerManifest() { + // dockerhub is the ID of the credentials stored in Jenkins + docker.withRegistry('https://index.docker.io/v1/', 'dockerhub') { + git poll: false, url: 'https://github.com/adoptium/infrastructure.git' + sh ''' + export TARGET="adoptopenjdk/centos7_build_image" + AMD64=$TARGET:linux-amd64 + ARM64=$TARGET:linux-arm64 + PPC64LE=$TARGET:linux-ppc64le + docker manifest create $TARGET $AMD64 $ARM64 $PPC64LE + docker manifest annotate $TARGET $AMD64 --arch amd64 --os linux + docker manifest annotate $TARGET $ARM64 --arch arm64 --os linux + docker manifest annotate $TARGET $PPC64LE --arch ppc64le --os linux + docker manifest push $TARGET + ''' + } +}