Skip to content
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

[ci] Custom revision parameter for Jenkins jobs #3419

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,21 @@ pipeline {
// disabled by default, but required for merge:
// opt-in with 'ci:extended-m1' tag on PR
booleanParam(name: 'extended_m1_ci', defaultValue: false, description: 'Enable M1 tests')

// allow overriding git revision for manually trigerred Jenkins builds
string(name: 'REVISION', defaultValue: '', description: 'the git branch to checkout (empty if default MBP approach)')
}
stages {
stage('Checkout') {
environment {
// Parameters will be empty for the very first build, setting an environment variable
// with the same name will workaround the issue. see JENKINS-41929
REVISION = "${params?.REVISION}"
}
steps {
pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ])
deleteDir()
gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true)
gitCheckout(basedir: "${BASE_DIR}", branches: [[name: "${params.REVISION}"]], githubNotifyFirstTimeContributor: true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is changing the default behaviour, if REVISION is optional, then, I'd say to keep the default behaviour if empty and checkout the given branch otherwise.

On the other hand, branches is not a valid argument for the gitCheckout -> https://github.com/elastic/apm-pipeline-library/tree/main/vars#gitcheckout

Suggested change
gitCheckout(basedir: "${BASE_DIR}", branches: [[name: "${params.REVISION}"]], githubNotifyFirstTimeContributor: true)
whenTrue("$REVISION" != "") {
gitCheckout(basedir: "${BASE_DIR}", branch: "${REVISION}", githubNotifyFirstTimeContributor: true)
}
whenFalse("$REVISION" != "") {
gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true)
}

stashV2(name: 'source', bucket: "${JOB_GCS_BUCKET}", credentialsId: "${JOB_GCS_CREDENTIALS}")
dir("${BASE_DIR}"){
setEnvVar('ONLY_DOCS', isGitRegionMatch(patterns: [ '.*\\.(asciidoc|md)' ], shouldMatchAll: true).toString())
Expand Down