|
| 1 | +pipeline { |
| 2 | + agent none |
| 3 | + stages { |
| 4 | + stage('Docker Build') { |
| 5 | + parallel { |
| 6 | + stage('Ubuntu24.04 x64') { |
| 7 | + agent { |
| 8 | + label "dockerBuild&&linux&&x64" |
| 9 | + } |
| 10 | + steps { |
| 11 | + dockerBuild('amd64', 'ubuntu2404', 'Dockerfile.u2404') |
| 12 | + } |
| 13 | + } |
| 14 | + stage('Ubuntu24.04 aarch64') { |
| 15 | + agent { |
| 16 | + label "dockerBuild&&linux&&aarch64" |
| 17 | + } |
| 18 | + steps { |
| 19 | + dockerBuild('arm64', 'ubuntu2404', 'Dockerfile.u2404') |
| 20 | + } |
| 21 | + } |
| 22 | + stage('UBI10 x64') { |
| 23 | + agent { |
| 24 | + label "dockerBuild&&linux&&x64" |
| 25 | + } |
| 26 | + steps { |
| 27 | + dockerBuild('amd64', 'ubi10', 'Dockerfile.ubi10') |
| 28 | + } |
| 29 | + } |
| 30 | + stage('UBI10 aarch64') { |
| 31 | + agent { |
| 32 | + label "dockerBuild&&linux&&aarch64" |
| 33 | + } |
| 34 | + steps { |
| 35 | + dockerBuild('arm64', 'ubi10', 'Dockerfile.ubi10') |
| 36 | + } |
| 37 | + } |
| 38 | +// stage('UBI10 ppc64le') { |
| 39 | +// agent { |
| 40 | +// label "dockerBuild&&linux&&ppc64le" |
| 41 | +// } |
| 42 | +// steps { |
| 43 | +// dockerBuild('ppc64le', 'ubi10', 'Dockerfile.ubi10') |
| 44 | +// } |
| 45 | +// } |
| 46 | + } |
| 47 | + } |
| 48 | + stage('Docker Manifest') { |
| 49 | + agent { |
| 50 | + label "dockerBuild&&linux&&x64" |
| 51 | + } |
| 52 | + environment { |
| 53 | + DOCKER_CLI_EXPERIMENTAL = "enabled" |
| 54 | + } |
| 55 | + steps { |
| 56 | + dockerManifest() |
| 57 | + } |
| 58 | + } |
| 59 | + stage('cosign') { |
| 60 | + agent { |
| 61 | + label "cosign" |
| 62 | + } |
| 63 | + environment { |
| 64 | + DOCKER_CLI_EXPERIMENTAL = "enabled" |
| 65 | + } |
| 66 | + steps { |
| 67 | + sh "rm -vf *.sha256" |
| 68 | + copyArtifacts( projectName: '${JOB_NAME}', selector: specific("${BUILD_ID}"), flatten: true ) |
| 69 | + sh "ls -ld *.sha256" |
| 70 | + cosign() |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +def dockerBuild(architecture, distro, staticdockerfile) { |
| 78 | + sh "rm -vf *.sha256" |
| 79 | + git poll: false, url: 'https://github.com/adoptium/infrastructure.git' |
| 80 | + def git_sha = "${env.GIT_COMMIT.trim()}" |
| 81 | + dockerImage = |
| 82 | + docker.build("ghcr.io/adoptium/test-containers:${distro}-${architecture}", |
| 83 | + "-f ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/$staticdockerfile .") |
| 84 | + // dockerhub is the ID of the credentials stored in Jenkins |
| 85 | + docker.withRegistry('https://ghcr.io', 'ghcr-adoptium') { |
| 86 | + dockerImage.push() |
| 87 | + sh "docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/adoptium/test-containers:${distro}-${architecture} > ${distro}_linux-${architecture}.sha256" |
| 88 | + archiveArtifacts artifacts: '*linux*.sha256', fingerprint: true |
| 89 | + } |
| 90 | +} |
| 91 | + |
| 92 | +def dockerManifest() { |
| 93 | + // dockerhub is the ID of the credentials stored in Jenkins |
| 94 | + docker.withRegistry('https://ghcr.io', 'ghcr-adoptium') { |
| 95 | + sh ''' |
| 96 | + # Ubuntu 24.04 |
| 97 | + export TARGET="ghcr.io/adoptium/test-containers:ubuntu2404" |
| 98 | + AMD64=${TARGET}-amd64 |
| 99 | + ARM64=${TARGET}-arm64 |
| 100 | + docker manifest create $TARGET $AMD64 $ARM64 |
| 101 | + docker manifest annotate $TARGET $AMD64 --arch amd64 --os linux |
| 102 | + docker manifest annotate $TARGET $ARM64 --arch arm64 --os linux |
| 103 | + docker manifest push $TARGET |
| 104 | + |
| 105 | + # UBI10 |
| 106 | + export TARGET="ghcr.io/adoptium/test-containers:ubi10" |
| 107 | + AMD64=${TARGET}-amd64 |
| 108 | + ARM64=${TARGET}-arm64 |
| 109 | +# PPC64LE=${TARGET}-ppc64le |
| 110 | + docker manifest create $TARGET $AMD64 $ARM64 # $PPC64LE |
| 111 | + docker manifest annotate $TARGET $AMD64 --arch amd64 --os linux |
| 112 | + docker manifest annotate $TARGET $ARM64 --arch arm64 --os linux |
| 113 | +# docker manifest annotate $TARGET $PPC64LE --arch ppc64le --os linux |
| 114 | + docker manifest push $TARGET |
| 115 | + ''' |
| 116 | + } |
| 117 | +} |
| 118 | +def cosign() { |
| 119 | + // dockerhub is the ID of the credentials stored in Jenkins |
| 120 | + docker.withRegistry('https://ghcr.io', 'ghcr-adoptium') { |
| 121 | + sh ''' |
| 122 | + curl -sSL -X POST --url https://auth.eclipse.org/auth/realms/foundation-service-accounts/protocol/openid-connect/token --header "Content-Type: application/x-www-form-urlencoded" --data @/home/jenkins/idp.txt | jq -r ".access_token" | head -c -1 > token.txt |
| 123 | + for IMAGE_SHA in *.sha256; do |
| 124 | + IMAGE="$(cat $IMAGE_SHA)" |
| 125 | + echo "Running cosign against image $IMAGE" |
| 126 | + cosign sign "$IMAGE" --oidc-issuer=https://auth.eclipse.org/auth/realms/foundation-service-accounts --identity-token=token.txt -y |
| 127 | + cosign verify "${IMAGE}" --certificate-oidc-issuer=https://auth.eclipse.org/auth/realms/foundation-service-accounts [email protected] |
| 128 | + done |
| 129 | + rm -vf token.txt |
| 130 | + ''' |
| 131 | + } |
| 132 | +} |
0 commit comments