-
Notifications
You must be signed in to change notification settings - Fork 543
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 5 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,158 @@ | ||
| #!/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" | ||
| } | ||
| 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}" | ||
| } | ||
| stage('Checkout') { | ||
| environment { | ||
| PATH = "${env.PATH}:${env.WORKSPACE}/bin" | ||
| HOME = "${env.WORKSPACE}" | ||
| } | ||
| options { skipDefaultCheckout() } | ||
| steps { | ||
| pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ]) | ||
| deleteDir() | ||
| gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true, | ||
|
v1v marked this conversation as resolved.
Outdated
|
||
| shallow: false, reference: "/var/lib/jenkins/.git-references/${REPO}.git") | ||
| stash allowEmpty: true, name: 'source', useDefaultExcludes: false | ||
| dir("${BASE_DIR}"){ | ||
| setEnvVar('ONLY_DOCS', isGitRegionMatch(patterns: [ '.*\\.asciidoc' ], comparator: 'regexp', shouldMatchAll: true)) | ||
| } | ||
|
v1v marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| stage('Package') { | ||
| // JOB_GCS_BUCKET contains the bucket and some folders, let's build the folder structure | ||
| environment { | ||
| URI_SUFFIX = "commits/${env.GIT_BASE_COMMIT}" | ||
| PATH_PREFIX = "${JOB_GCS_BUCKET.contains('/') ? JOB_GCS_BUCKET.substring(JOB_GCS_BUCKET.indexOf('/') + 1) + '/' + env.URI_SUFFIX : env.URI_SUFFIX}" | ||
| BUCKET_URI = """${isPR() ? "gs://${JOB_GCS_BUCKET}/pull-requests/pr-${env.CHANGE_ID}" : "gs://${JOB_GCS_BUCKET}/snapshots"}""" | ||
| } | ||
| options { skipDefaultCheckout() } | ||
| matrix { | ||
| agent { | ||
| label "${PLATFORM}" | ||
| } | ||
| axes { | ||
| axis { | ||
| name 'PLATFORM' | ||
| values 'linux && immutable', 'arm' | ||
| } | ||
| } | ||
| stages { | ||
| stage('Package') { | ||
| environment { | ||
| PLATFORMS = "${isArm() ? 'linux/arm64' : 'linux/amd64'}" | ||
| PACKAGES = "${isArm() ? 'docker' : ''}" | ||
| } | ||
| steps { | ||
| deleteDir() | ||
| unstash 'source' | ||
| dir("${BASE_DIR}"){ | ||
| withMageEnv() { | ||
| sh(label: 'Build packages', script: './.ci/scripts/package.sh') | ||
| } | ||
| } | ||
| } | ||
| } | ||
| 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) | ||
| 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}") { | ||
| script { | ||
| getVaultSecret.readSecretWrapper { | ||
| sh(label: 'release-manager.sh', script: '.ci/scripts/release-manager.sh') | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| post { | ||
| cleanup { | ||
| notifyBuildResult() | ||
| } | ||
| failure { | ||
| echo 'disabled' | ||
| // 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,33 @@ | ||
| #!/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.
|
||
| # 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.