Skip to content

Commit

Permalink
[7.17](backport #31073) ci: DRA enhancements (#31090)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Mar 31, 2022
1 parent fd21054 commit d91bb8a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 74 deletions.
37 changes: 25 additions & 12 deletions .ci/packaging.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pipeline {
}
stages {
stage('Filter build') {
options { skipDefaultCheckout() }
agent { label 'ubuntu-20 && immutable' }
when {
beforeAgent true
Expand Down Expand Up @@ -106,6 +107,7 @@ pipeline {
}
}
stage('DRA') {
options { skipDefaultCheckout() }
// The Unified Release process keeps moving branches as soon as a new
// minor version is created, therefore old release branches won't be able
// to use the release manager as their definition is removed.
Expand All @@ -118,6 +120,7 @@ pipeline {
environment {
// It uses the folder structure done in uploadPackagesToGoogleBucket
BUCKET_URI = "gs://${env.JOB_GCS_BUCKET}/${env.REPO}/commits/${env.GIT_BASE_COMMIT}"
DRA_OUTPUT = 'release-manager.out'
}
steps {
dir("${BASE_DIR}") {
Expand All @@ -127,17 +130,21 @@ pipeline {
sh(label: 'move one level up', script: "mv ${env.GIT_BASE_COMMIT}/** .")
}
sh(label: "debug package", script: 'find build/distributions -type f -ls || true')
sh(label: 'prepare-release-manager-artifacts', script: ".ci/scripts/prepare-release-manager.sh")
dockerLogin(secret: env.DOCKERELASTIC_SECRET, registry: env.DOCKER_REGISTRY)
script {
getVaultSecret.readSecretWrapper {
sh(label: 'release-manager.sh', script: '.ci/scripts/release-manager.sh')
}
}
releaseManager(project: 'beats',
version: env.BEAT_VERSION,
type: 'snapshot',
artifactsFolder: 'build/distributions',
outputFile: env.DRA_OUTPUT)
}
}
post {
failure {
notifyStatus(slackStatus: 'danger', subject: "[${env.REPO}@${env.BRANCH_NAME}] DRA failed", body: "Build: (<${env.RUN_DISPLAY_URL}|here>)")
notifyStatus(analyse: true,
file: "${BASE_DIR}/${env.DRA_OUTPUT}",
subject: "[${env.REPO}@${env.BRANCH_NAME}] The Daily releasable artifact failed.",
body: 'Contact the Release Platform team [#platform-release]')
}
}
}
Expand Down Expand Up @@ -406,10 +413,16 @@ def withBeatsEnv(Closure body) {
}

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)
def releaseManagerFile = args.get('file', '')
def analyse = args.get('analyse', false)
def subject = args.get('subject', '')
def body = args.get('body', '')
releaseManagerNotification(file: releaseManagerFile,
analyse: analyse,
slackChannel: "${env.SLACK_CHANNEL}",
slackColor: 'danger',
slackCredentialsId: 'jenkins-slack-integration-token',
to: "${env.NOTIFY_TO}",
subject: subject,
body: "Build: (<${env.RUN_DISPLAY_URL}|here>).\n ${body}")
}
38 changes: 38 additions & 0 deletions .ci/scripts/prepare-release-manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
#
# This script is executed by the DRA stage.
# It prepares the required files to be consumed by the release-manager
# It can be published as snapshot or staging, for such you use
# the paramater $0 "snapshot" or $0 "staging"
#
set -ueo pipefail

readonly TYPE=${1:-snapshot}

# rename dependencies.csv to the name expected by release-manager.
VERSION=$(make get-version)
FINAL_VERSION=$VERSION-SNAPSHOT
if [ "$TYPE" != "snapshot" ] ; then
FINAL_VERSION=$VERSION
fi
VERSION=$(make get-version)
mv build/distributions/dependencies.csv \
build/distributions/dependencies-"$FINAL_VERSION".csv

# 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
# See https://github.com/elastic/beats/pull/30895
find build/distributions -name '*linux-arm64.docker.tar.gz*' -print0 |
while IFS= read -r -d '' file
do
echo "Rename file $file"
mv "$file" "${file/linux-arm64.docker.tar.gz/docker-image-linux-arm64.tar.gz}"
done

find build/distributions -name '*linux-amd64.docker.tar.gz*' -print0 |
while IFS= read -r -d '' file
do
echo "Rename file $file"
mv "$file" "${file/linux-amd64.docker.tar.gz/docker-image-linux-amd64.tar.gz}"
done
62 changes: 0 additions & 62 deletions .ci/scripts/release-manager.sh

This file was deleted.

0 comments on commit d91bb8a

Please sign in to comment.