From b80c9a48576a935a9bf4f8e1542538a1b9cc0e3c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 24 Nov 2022 14:49:12 +0000 Subject: [PATCH] ci: change slack channel (#33796) (cherry picked from commit a1a6bd8cd569182aeb0082e252ecbabad338a797) # Conflicts: # .ci/ironbank-validation.groovy --- .ci/ironbank-validation.groovy | 110 +++++++++++++++++++++++++++++++++ .ci/packaging.groovy | 2 +- Jenkinsfile | 2 +- 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 .ci/ironbank-validation.groovy diff --git a/.ci/ironbank-validation.groovy b/.ci/ironbank-validation.groovy new file mode 100644 index 000000000000..02679a77b1ba --- /dev/null +++ b/.ci/ironbank-validation.groovy @@ -0,0 +1,110 @@ +#!/usr/bin/env groovy + +@Library('apm@current') _ + +pipeline { + agent { label 'ubuntu-20 && immutable' } + environment { + REPO = 'beats' + BASE_DIR = "src/github.com/elastic/${env.REPO}" + PIPELINE_LOG_LEVEL = "INFO" + BEATS_FOLDER = "x-pack/heartbeat" + SLACK_CHANNEL = '#ingest-notifications' + NOTIFY_TO = 'observability-robots-internal+ironbank-beats-validation@elastic.co' + } + options { + timeout(time: 1, unit: 'HOURS') + buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30')) + timestamps() + ansiColor('xterm') + disableResume() + durabilityHint('PERFORMANCE_OPTIMIZED') + disableConcurrentBuilds() + } + stages { + stage('Checkout') { + options { skipDefaultCheckout() } + steps { + deleteDir() + gitCheckout(basedir: "${BASE_DIR}") + setEnvVar("GO_VERSION", readFile("${BASE_DIR}/.go-version").trim()) + dir("${BASE_DIR}"){ + setEnvVar('BEAT_VERSION', sh(label: 'Get beat version', script: 'make get-version', returnStdout: true)?.trim()) + } + } + } + stage('Package'){ + options { skipDefaultCheckout() } + steps { + withMageEnv(){ + dir("${env.BASE_DIR}/${env.BEATS_FOLDER}") { + sh(label: 'make ironbank-package', script: "make -C ironbank package") + } + } + } + post { + failure { + notifyStatus(slackStatus: 'danger', subject: "[${env.REPO}@${BRANCH_NAME}] package for ${env.BEATS_FOLDER}", body: "Contact the heartbeats team. (<${env.RUN_DISPLAY_URL}|Open>)") + } + } + } + stage('Ironbank'){ + options { skipDefaultCheckout() } + steps { + withMageEnv(){ + dir("${env.BASE_DIR}/${env.BEATS_FOLDER}") { + sh(label: 'mage ironbank', script: 'mage ironbank') + } + } + } + post { + failure { + notifyStatus(slackStatus: 'danger', subject: "[${env.REPO}@${BRANCH_NAME}] Ironbank docker context for ${env.BEATS_FOLDER}", body: "Contact the @observablt-robots-team team. (<${env.RUN_DISPLAY_URL}|Open>)") + } + } + } + stage('Pre-flight'){ + options { skipDefaultCheckout() } + environment { + DOCKER_ELASTIC_SECRET = 'secret/observability-team/ci/docker-registry/prod' + DOCKER_REGISTRY = 'docker.elastic.co' + } + steps { + // verify if the docker registry is available by using the dockerLogin step + // if so then run the validation which interacts with third party systems + retryWithSleep(retries: 3, seconds: 10, backoff: true) { + dockerLogin(secret: "${DOCKER_ELASTIC_SECRET}", registry: "${DOCKER_REGISTRY}") + } + } + } + stage('Validate'){ + options { skipDefaultCheckout() } + steps { + withMageEnv(){ + dir("${env.BASE_DIR}/${env.BEATS_FOLDER}") { + sh(label: 'make validate-ironbank', script: "make -C ironbank validate-ironbank") + } + } + } + post { + failure { + notifyStatus(slackStatus: 'danger', subject: "[${env.REPO}@${BRANCH_NAME}] Ironbank validation failed", body: "Contact the @observablt-robots-team team. (<${env.RUN_DISPLAY_URL}|Open>)") + } + } + } + } + post { + cleanup { + notifyBuildResult(prComment: true) + } + } +} + +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) +} diff --git a/.ci/packaging.groovy b/.ci/packaging.groovy index c5998090bc8a..ee325284c5da 100644 --- a/.ci/packaging.groovy +++ b/.ci/packaging.groovy @@ -22,7 +22,7 @@ pipeline { DOCKER_REGISTRY = 'docker.elastic.co' GITHUB_CHECK_E2E_TESTS_NAME = 'E2E Tests' PIPELINE_LOG_LEVEL = "INFO" - SLACK_CHANNEL = '#beats' + SLACK_CHANNEL = '#ingest-notifications' NOTIFY_TO = 'beats-contrib+package-beats@elastic.co' DRA_OUTPUT = 'release-manager.out' } diff --git a/Jenkinsfile b/Jenkinsfile index c30a4d5258be..10d0698feaa5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ pipeline { PIPELINE_LOG_LEVEL = 'INFO' PYTEST_ADDOPTS = "${params.PYTEST_ADDOPTS}" RUNBLD_DISABLE_NOTIFICATIONS = 'true' - SLACK_CHANNEL = "#beats" + SLACK_CHANNEL = "#ingest-notifications" SNAPSHOT = 'true' TERRAFORM_VERSION = "0.13.7" XPACK_MODULE_PATTERN = '^x-pack\\/[a-z0-9]+beat\\/module\\/([^\\/]+)\\/.*'