-
Notifications
You must be signed in to change notification settings - Fork 5k
[PACKAGING] Push docker images with the architecture in the version #24121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e810a71
[CI] Use script to tag/push
v1v 517ed15
Cosmetic
v1v 1d9d1ef
Add multiplaform manifest
v1v f92b5b3
Use args and enable multiplaform
v1v a8ab253
Avoid multiplatform manifest for simplicity
v1v 4615a5a
Enable packaging with the docker arch
v1v 91f575d
Revert "chore: comment out the E2E (#24109)"
v1v 2c64feb
Create AMD64 docker images without the arch in the versioning
v1v 446c7e1
Update .ci/packaging.groovy
v1v File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,7 +152,9 @@ pipeline { | |
| withGithubNotify(context: "Packaging Linux ${BEATS_FOLDER}") { | ||
| deleteDir() | ||
| release() | ||
| pushCIDockerImages() | ||
| dir("${BASE_DIR}"){ | ||
| pushCIDockerImages(arch: 'amd64') | ||
| } | ||
| } | ||
| prepareE2ETestForPackage("${BEATS_FOLDER}") | ||
| } | ||
|
|
@@ -234,7 +236,9 @@ pipeline { | |
| withGithubNotify(context: "Packaging linux/arm64 ${BEATS_FOLDER}") { | ||
| deleteWorkspace() | ||
| release() | ||
| pushCIDockerImages() | ||
| dir("${BASE_DIR}"){ | ||
| pushCIDockerImages(arch: 'arm64') | ||
| } | ||
| } | ||
| } | ||
| post { | ||
|
|
@@ -247,15 +251,13 @@ pipeline { | |
| } | ||
| } | ||
| } | ||
| /* | ||
| stage('Run E2E Tests for Packages'){ | ||
| agent { label 'ubuntu-18 && immutable' } | ||
| options { skipDefaultCheckout() } | ||
| steps { | ||
| runE2ETests() | ||
| } | ||
| } | ||
| */ | ||
| } | ||
| post { | ||
| success { | ||
|
|
@@ -272,27 +274,37 @@ pipeline { | |
| } | ||
| } | ||
|
|
||
| def pushCIDockerImages(){ | ||
| /** | ||
| * @param arch what architecture | ||
| */ | ||
| def pushCIDockerImages(Map args = [:]) { | ||
| def arch = args.get('arch', 'amd64') | ||
| catchError(buildResult: 'UNSTABLE', message: 'Unable to push Docker images', stageResult: 'FAILURE') { | ||
| if (env?.BEATS_FOLDER?.endsWith('auditbeat')) { | ||
| tagAndPush('auditbeat') | ||
| tagAndPush(beatName: 'auditbeat', arch: arch) | ||
| } else if (env?.BEATS_FOLDER?.endsWith('filebeat')) { | ||
| tagAndPush('filebeat') | ||
| tagAndPush(beatName: 'filebeat', arch: arch) | ||
| } else if (env?.BEATS_FOLDER?.endsWith('heartbeat')) { | ||
| tagAndPush('heartbeat') | ||
| tagAndPush(beatName: 'heartbeat', arch: arch) | ||
| } else if ("${env.BEATS_FOLDER}" == "journalbeat"){ | ||
| tagAndPush('journalbeat') | ||
| tagAndPush(beatName: 'journalbeat', arch: arch) | ||
| } else if (env?.BEATS_FOLDER?.endsWith('metricbeat')) { | ||
| tagAndPush('metricbeat') | ||
| tagAndPush(beatName: 'metricbeat', arch: arch) | ||
| } else if ("${env.BEATS_FOLDER}" == "packetbeat"){ | ||
| tagAndPush('packetbeat') | ||
| tagAndPush(beatName: 'packetbeat', arch: arch) | ||
| } else if ("${env.BEATS_FOLDER}" == "x-pack/elastic-agent") { | ||
| tagAndPush('elastic-agent') | ||
| tagAndPush(beatName: 'elastic-agent', arch: arch) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| def tagAndPush(beatName){ | ||
| /** | ||
| * @param beatName name of the Beat | ||
| * @param arch what architecture | ||
| */ | ||
| def tagAndPush(Map args = [:]) { | ||
| def beatName = args.beatName | ||
| def arch = args.get('arch', 'amd64') | ||
| def libbetaVer = env.BEAT_VERSION | ||
| def aliasVersion = "" | ||
| if("${env.SNAPSHOT}" == "true"){ | ||
|
|
@@ -309,14 +321,22 @@ def tagAndPush(beatName){ | |
|
|
||
| dockerLogin(secret: "${DOCKERELASTIC_SECRET}", registry: "${DOCKER_REGISTRY}") | ||
|
|
||
| // supported tags | ||
| def tags = [tagName, "${env.GIT_BASE_COMMIT}"] | ||
| if (!isPR() && aliasVersion != "") { | ||
| tags << aliasVersion | ||
| } | ||
| // supported image flavours | ||
| def variants = ["", "-oss", "-ubi8"] | ||
| variants.each { variant -> | ||
| doTagAndPush(beatName, variant, libbetaVer, tagName) | ||
| doTagAndPush(beatName, variant, libbetaVer, "${env.GIT_BASE_COMMIT}") | ||
|
|
||
| if (!isPR() && aliasVersion != "") { | ||
| doTagAndPush(beatName, variant, libbetaVer, aliasVersion) | ||
| tags.each { tag -> | ||
| // TODO: | ||
| // For backward compatibility let's ensure we tag only for amd64, then E2E can benefit from until | ||
| // they support the versioning with the architecture | ||
| if ("${arch}" == "amd64") { | ||
| doTagAndPush(beatName: beatName, variant: variant, sourceTag: libbetaVer, targetTag: "${tag}") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We addressed the change in elastic/e2e-testing#787 |
||
| } | ||
| doTagAndPush(beatName: beatName, variant: variant, sourceTag: libbetaVer, targetTag: "${tag}-${arch}") | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -327,18 +347,19 @@ def tagAndPush(beatName){ | |
| * @param sourceTag tag to be used as source for the docker tag command, usually under the 'beats' namespace | ||
| * @param targetTag tag to be used as target for the docker tag command, usually under the 'observability-ci' namespace | ||
| */ | ||
| def doTagAndPush(beatName, variant, sourceTag, targetTag) { | ||
| def doTagAndPush(Map args = [:]) { | ||
| def beatName = args.beatName | ||
| def variant = args.variant | ||
| def sourceTag = args.sourceTag | ||
| def targetTag = args.targetTag | ||
| def sourceName = "${DOCKER_REGISTRY}/beats/${beatName}${variant}:${sourceTag}" | ||
| def targetName = "${DOCKER_REGISTRY}/observability-ci/${beatName}${variant}:${targetTag}" | ||
|
|
||
| def iterations = 0 | ||
| retryWithSleep(retries: 3, seconds: 5, backoff: true) { | ||
| iterations++ | ||
| def status = sh(label: "Change tag and push ${targetName}", script: """ | ||
| docker tag ${sourceName} ${targetName} | ||
| docker push ${targetName} | ||
| """, returnStatus: true) | ||
|
|
||
| def status = sh(label: "Change tag and push ${targetName}", | ||
| script: ".ci/scripts/docker-tag-push.sh ${sourceName} ${targetName}", | ||
| returnStatus: true) | ||
| if ( status > 0 && iterations < 3) { | ||
| error("tag and push failed for ${beatName}, retry") | ||
| } else if ( status > 0 ) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/usr/bin/env bash | ||
| set -exuo pipefail | ||
| MSG="parameter missing." | ||
| SOURCE_IMAGE=${1:?$MSG} | ||
| TARGET_IMAGE=${2:?$MSG} | ||
|
|
||
| if docker image inspect "${SOURCE_IMAGE}" &> /dev/null ; then | ||
| docker tag "${SOURCE_IMAGE}" "${TARGET_IMAGE}" | ||
| docker push "${TARGET_IMAGE}" | ||
| else | ||
| echo "docker image ${SOURCE_IMAGE} does not exist" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.