Skip to content

Commit

Permalink
[7.17](backport #1439) ci: use downstream pattern (#1443)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored May 10, 2022
1 parent 6ed855b commit 888b031
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
12 changes: 12 additions & 0 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
28 changes: 21 additions & 7 deletions .ci/packaging.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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') {
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -113,7 +113,6 @@ pipeline {
}
}
}

stage('DRA Snapshot') {
options { skipDefaultCheckout() }
// The Unified Release process keeps moving branches as soon as a new
Expand Down Expand Up @@ -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")
}
}

0 comments on commit 888b031

Please sign in to comment.