diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 6910e5c33..03738c943 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -121,6 +121,18 @@ pipeline { } } } + stage('Downstream - Package') { + options { skipDefaultCheckout() } + when { + not { changeRequest() } + } + steps { + build(job: "Ingest-manager/fleet-server-package-mbp/${env.JOB_BASE_NAME}", + propagate: false, + wait: false, + parameters: [string(name: 'COMMIT', value: "${env.GIT_BASE_COMMIT}")]) + } + } } post { cleanup { diff --git a/.ci/packaging.groovy b/.ci/packaging.groovy index d14ccba19..4e8d6760f 100644 --- a/.ci/packaging.groovy +++ b/.ci/packaging.groovy @@ -13,6 +13,8 @@ pipeline { DOCKER_SECRET = 'secret/observability-team/ci/docker-registry/prod' DOCKER_REGISTRY = 'docker.elastic.co' DRA_OUTPUT = 'release-manager.out' + COMMIT = "${params?.COMMIT}" + JOB_GIT_CREDENTIALS = "f6c7695a-671e-4f4f-a331-acdce44ff9ba" } options { timeout(time: 2, unit: 'HOURS') @@ -24,9 +26,8 @@ pipeline { rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true]) quietPeriod(10) } - triggers { - // disable upstream trigger on a PR basis - upstream("Ingest-manager/fleet-server/${ env.JOB_BASE_NAME.startsWith('PR-') ? 'none' : env.JOB_BASE_NAME }") + parameters { + string(name: 'COMMIT', defaultValue: '', description: 'The Git commit to be used (empty will checkout the latest commit)') } stages { stage('Filter build') { @@ -58,9 +59,8 @@ pipeline { 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 + smartGitCheckout() + stash(allowEmpty: true, name: 'source', useDefaultExcludes: false) setEnvVar('IS_BRANCH_AVAILABLE', isBranchUnifiedReleaseAvailable(env.BRANCH_NAME)) dir("${BASE_DIR}") { setEnvVar('VERSION', sh(label: 'Get version', script: 'make get-version', returnStdout: true)?.trim()) @@ -113,7 +113,6 @@ pipeline { } } } - stage('DRA Snapshot') { options { skipDefaultCheckout() } // The Unified Release process keeps moving branches as soon as a new @@ -250,3 +249,18 @@ def runIfNoMainAndNoStaging(Closure body) { body() } } + +def smartGitCheckout() { + // Checkout the given commit + if (env.COMMIT?.trim()) { + gitCheckout(basedir: "${BASE_DIR}", + branch: "${env.COMMIT}", + credentialsId: "${JOB_GIT_CREDENTIALS}", + repo: "https://github.com/elastic/${REPO}.git") + } else { + gitCheckout(basedir: "${BASE_DIR}", + githubNotifyFirstTimeContributor: false, + shallow: false, + reference: "/var/lib/jenkins/.git-references/${REPO}.git") + } +}