Skip to content
Merged
Show file tree
Hide file tree
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
27 changes: 26 additions & 1 deletion Jenkinsfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions ci/jenkins/Prepare.groovy.j2
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def init_git() {
""",
label: 'Update git submodules',
)
checkout_trusted_files()
}

def docker_init(image) {
Expand Down Expand Up @@ -98,6 +99,30 @@ def cancel_previous_build() {
}
}

def checkout_trusted_files() {
// trust everything from branch builds
if (!env.BRANCH_NAME.startsWith('PR-')) {
return;
}

// trust peoople listed in CONTRIBUTING.md
grep_code = sh(
returnStatus: true,
script: "git show '${upstream_revision}:CONTRIBUTORS.md' | grep '@${env.CHANGE_AUTHOR}'",
label: 'Check if change is from a contributor',
)

if (grep_code == 1) {
// Any scripts that run on the bare host and not inside a Docker container
// (especially those that access secrets) should be checked out here so
// only trusted versions are used in CI
sh(
script: "git checkout ${upstream_revision} ci/scripts/.",
label: 'Check out trusted files',
)
}
}

def should_skip_ci(pr_number) {
if (env.BRANCH_NAME == null || !env.BRANCH_NAME.startsWith('PR-')) {
// never skip CI on build sourced from a branch
Expand Down