-
Notifications
You must be signed in to change notification settings - Fork 539
ci: Daily Releasable Artifacts pipeline #7530
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
Changes from 27 commits
1c7881a
4a04d32
5cf7081
a1fa0eb
86c9739
e5e2c13
8389e2a
59a4c62
bd3da2d
0b3b09a
094c6ff
b43bd25
15985ea
550a282
4d47175
f8c1a09
e461a46
acf7deb
c6c947e
0c99209
bce8a2d
75585b9
415d7fd
ec2d59e
779c26f
a9c34a8
7a87a44
162e9ff
7879586
b150e2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| #!/usr/bin/env groovy | ||
| @Library('apm@current') _ | ||
|
|
||
| pipeline { | ||
| agent none | ||
| environment { | ||
| REPO = 'apm-server' | ||
| BASE_DIR = "src/github.com/elastic/${env.REPO}" | ||
| SLACK_CHANNEL = '#apm-server' | ||
| NOTIFY_TO = 'build-apm+apm-server@elastic.co' | ||
| JOB_GCS_BUCKET = credentials('gcs-bucket') | ||
| JOB_GCS_CREDENTIALS = 'apm-ci-gcs-plugin' | ||
| SNAPSHOT = "true" | ||
| DOCKER_SECRET = 'secret/apm-team/ci/docker-registry/prod' | ||
| DOCKER_REGISTRY = 'docker.elastic.co' | ||
| } | ||
| options { | ||
| timeout(time: 2, unit: 'HOURS') | ||
| buildDiscarder(logRotator(numToKeepStr: '100', artifactNumToKeepStr: '30', daysToKeepStr: '30')) | ||
| timestamps() | ||
| ansiColor('xterm') | ||
| disableResume() | ||
| durabilityHint('PERFORMANCE_OPTIMIZED') | ||
| rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true]) | ||
| quietPeriod(10) | ||
| } | ||
| triggers { | ||
| // disable upstream trigger on a PR basis | ||
| upstream("apm-server/apm-server-mbp/${ env.JOB_BASE_NAME.startsWith('PR-') ? 'none' : env.JOB_BASE_NAME }") | ||
| } | ||
| stages { | ||
| stage('Filter build') { | ||
| agent { label 'ubuntu-18 && immutable' } | ||
| when { | ||
| beforeAgent true | ||
| anyOf { | ||
| triggeredBy cause: "IssueCommentCause" | ||
| expression { | ||
| def ret = isUserTrigger() || isUpstreamTrigger() | ||
| if(!ret){ | ||
| currentBuild.result = 'NOT_BUILT' | ||
| currentBuild.description = "The build has been skipped" | ||
| currentBuild.displayName = "#${BUILD_NUMBER}-(Skipped)" | ||
| echo("the build has been skipped due the trigger is a branch scan and the allow ones are manual, GitHub comment, and upstream job") | ||
| } | ||
| return ret | ||
| } | ||
| } | ||
| } | ||
| environment { | ||
| PATH = "${env.PATH}:${env.WORKSPACE}/bin" | ||
| HOME = "${env.WORKSPACE}" | ||
| } | ||
| stages { | ||
| stage('Checkout') { | ||
| options { skipDefaultCheckout() } | ||
| steps { | ||
| pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ]) | ||
| deleteDir() | ||
| gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: false, | ||
| shallow: false, reference: "/var/lib/jenkins/.git-references/${REPO}.git") | ||
| stash allowEmpty: true, name: 'source', useDefaultExcludes: false | ||
| // set environment variables globally since they are used afterwards but GIT_BASE_COMMIT won't | ||
| // be available until gitCheckout is executed. | ||
| setEnvVar('URI_SUFFIX', "commits/${env.GIT_BASE_COMMIT}") | ||
| // JOB_GCS_BUCKET contains the bucket and some folders, let's build the folder structure | ||
| setEnvVar('PATH_PREFIX', "${JOB_GCS_BUCKET.contains('/') ? JOB_GCS_BUCKET.substring(JOB_GCS_BUCKET.indexOf('/') + 1) + '/' + env.URI_SUFFIX : env.URI_SUFFIX}") | ||
| } | ||
| } | ||
| stage('Package') { | ||
| options { skipDefaultCheckout() } | ||
| matrix { | ||
| agent { | ||
| label "${PLATFORM}" | ||
| } | ||
| axes { | ||
| axis { | ||
| name 'PLATFORM' | ||
| values 'linux && immutable', 'arm' | ||
| } | ||
| } | ||
| stages { | ||
| stage('Package') { | ||
| environment { | ||
| PLATFORMS = "${isArm() ? 'linux/arm64' : ''}" | ||
| PACKAGES = "${isArm() ? 'docker' : ''}" | ||
| } | ||
| steps { | ||
| deleteDir() | ||
| unstash 'source' | ||
| dir("${BASE_DIR}"){ | ||
| withMageEnv() { | ||
| sh(label: 'make release-manager-snapshot', script: 'make release-manager-snapshot') | ||
|
Member
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. I just realised we're only ever building/publishing snapshot images. We'll need to also build staging images for release branches.
Member
Author
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. I somehow missed this particular bit, we can iterate on this after merging this PR, what do you think?
Member
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. Yes I think that's fine. |
||
| } | ||
| } | ||
| } | ||
| } | ||
| stage('Publish') { | ||
| steps { | ||
| // Copy those files to another location with the sha commit to test them afterward. | ||
| googleStorageUpload(bucket: "gs://${JOB_GCS_BUCKET}/${URI_SUFFIX}", | ||
| credentialsId: "${JOB_GCS_CREDENTIALS}", | ||
| pathPrefix: "${BASE_DIR}/build/distributions/", | ||
| pattern: "${BASE_DIR}/build/distributions/**/*", | ||
| sharedPublicly: true, | ||
| showInline: true) | ||
| // Copy the dependencies files if no ARM | ||
| whenFalse(isArm()) { | ||
| googleStorageUpload(bucket: "gs://${JOB_GCS_BUCKET}/${URI_SUFFIX}", | ||
| credentialsId: "${JOB_GCS_CREDENTIALS}", | ||
| pathPrefix: "${BASE_DIR}/build/", | ||
| pattern: "${BASE_DIR}/build/dependencies.csv", | ||
| sharedPublicly: true, | ||
| showInline: true) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| stage('DRA') { | ||
| steps { | ||
| googleStorageDownload(bucketUri: "gs://${JOB_GCS_BUCKET}/${URI_SUFFIX}/*", | ||
| credentialsId: "${JOB_GCS_CREDENTIALS}", | ||
| localDirectory: "${BASE_DIR}/build/distributions", | ||
| pathPrefix: env.PATH_PREFIX) | ||
| dir("${BASE_DIR}") { | ||
| dockerLogin(secret: env.DOCKER_SECRET, registry: env.DOCKER_REGISTRY) | ||
| script { | ||
| getVaultSecret.readSecretWrapper { | ||
| sh(label: 'release-manager.sh', script: '.ci/scripts/release-manager.sh') | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| post { | ||
| cleanup { | ||
| notifyBuildResult() | ||
| } | ||
| failure { | ||
| notifyStatus(slackStatus: 'danger', subject: "[${env.REPO}] DRA failed", body: "Build: (<${env.RUN_DISPLAY_URL}|here>)") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| def notifyStatus(def args = [:]) { | ||
| releaseNotification(slackChannel: "${env.SLACK_CHANNEL}", | ||
| slackColor: args.slackStatus, | ||
| slackCredentialsId: 'jenkins-slack-integration-token', | ||
| to: "${env.NOTIFY_TO}", | ||
| subject: args.subject, | ||
| body: args.body) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,8 @@ set -euo pipefail | |
| NEW_TAG=${1:?Docker tag is not set} | ||
| NEW_IMAGE=${2:?Docker image is not set} | ||
|
|
||
| export PLATFORMS='linux/amd64' | ||
| # linux/amd64 is in the default list already | ||
| export PLATFORMS="${PLATFORMS:-+linux/amd64}" | ||
|
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. IIRC
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. I dunno which behaviour we want here
Member
Author
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. In fact, I don't need this anymore, it was wrongly copied from another PR that I worked with
v1v marked this conversation as resolved.
Outdated
|
||
| export TYPE='docker' | ||
| export SNAPSHOT='true' | ||
| export IMAGE="docker.elastic.co/apm/apm-server" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # This script is executed by the release snapshot stage. | ||
| # It requires the below environment variables: | ||
| # - BRANCH_NAME | ||
| # - VAULT_ADDR | ||
| # - VAULT_ROLE_ID | ||
| # - VAULT_SECRET_ID | ||
| # | ||
| set -uexo pipefail | ||
|
|
||
| # set required permissions on artifacts and directory | ||
| chmod -R a+r build/distributions/* | ||
| chmod -R a+w build/distributions | ||
|
|
||
|
v1v marked this conversation as resolved.
|
||
| # rename docker files to support the unified release format. | ||
| # TODO: this could be supported by the package system itself | ||
| # or the unified release process the one to do the transformation | ||
| for i in build/distributions/*linux-arm64.docker.tar.gz* | ||
| do | ||
| mv "$i" "${i/linux-arm64.docker.tar.gz/docker-image-arm64.tar.gz}" | ||
| done | ||
|
|
||
| for i in build/distributions/*linux-amd64.docker.tar.gz* | ||
| do | ||
| mv "$i" "${i/linux-amd64.docker.tar.gz/docker-image.tar.gz}" | ||
| done | ||
|
|
||
|
Comment on lines
+21
to
+33
Member
Author
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. I have not seen where this could be changed in the I asked the release platform team whether this could be done within the unified release process, still an open discussion. Ivan pointed to change this in the generators, though I don't know the impact from the consumers, but we can figure out
Member
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. Pretty certain it's part of Beats's mage stuff. I think
Member
Author
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. I just raised elastic/beats#30895 though, it's still in a very early stage... and I've no clue if there is any corner cases that could happen if changing the filename. It's always scary to change the packaging system |
||
| # ensure the latest image has been pulled | ||
| IMAGE=docker.elastic.co/infra/release-manager:latest | ||
| docker pull --quiet $IMAGE | ||
|
|
||
| # Generate checksum files and upload to GCS | ||
| docker run --rm \ | ||
| --name release-manager \ | ||
| -e VAULT_ADDR \ | ||
| -e VAULT_ROLE_ID \ | ||
| -e VAULT_SECRET_ID \ | ||
| --mount type=bind,readonly=false,src="$PWD",target=/artifacts \ | ||
| "$IMAGE" \ | ||
| cli collect \ | ||
| --project apm-server \ | ||
| --branch "$BRANCH_NAME" \ | ||
| --commit "$(git rev-parse HEAD)" \ | ||
| --workflow "snapshot" \ | ||
| --artifact-set main | ||
Uh oh!
There was an error while loading. Please reload this page.