Skip to content

Commit b5e82cf

Browse files
committed
Enable selective testing of integrations on main and backport branches
Running tests for all integrations on all branches launches dozens of jobs. If multiple branches are merged in a short period of time, this can overload CI.
1 parent bc1802f commit b5e82cf

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

.ci/Jenkinsfile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,20 @@ def isPrAffected(integrationName) {
272272
}
273273
}
274274

275-
if (env.BRANCH_NAME == "main") {
276-
echo "[${integrationName}] PR is affected: running on main branch"
277-
return true
275+
def from = "";
276+
def to = "";
277+
if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME.startsWith('backport-')) {
278+
echo "[${integrationName}] PR is affected: running on ${env.BRANCH_NAME} branch"
279+
from = "origin/${env.BRANCH_NAME}"
280+
// If GIT_PREVIOUS_COMMIT is not available, check with previous commit in the branch, this should
281+
// be the same as we are squashing and merging single commits.
282+
to = "env.GIT_PREVIOUS_COMMIT?.trim()" ? env.GIT_PREVIOUS_COMMIT : "origin/${env.BRANCH_NAME}^"
283+
} else {
284+
// Source: https://github.com/elastic/apm-pipeline-library/blob/721115cf0fdb2b5a4e1cb6a576bfbb7035d14485/vars/getGitMatchingGroup.groovy#L40-L41
285+
from = env.CHANGE_TARGET?.trim() ? "origin/${env.CHANGE_TARGET}" : "${env.GIT_PREVIOUS_COMMIT?.trim() ? env.GIT_PREVIOUS_COMMIT : env.GIT_BASE_COMMIT}"
286+
to = env.GIT_BASE_COMMIT
278287
}
279288

280-
// Source: https://github.com/elastic/apm-pipeline-library/blob/721115cf0fdb2b5a4e1cb6a576bfbb7035d14485/vars/getGitMatchingGroup.groovy#L40-L41
281-
def from = env.CHANGE_TARGET?.trim() ? "origin/${env.CHANGE_TARGET}" : "${env.GIT_PREVIOUS_COMMIT?.trim() ? env.GIT_PREVIOUS_COMMIT : env.GIT_BASE_COMMIT}"
282-
def to = env.GIT_BASE_COMMIT
283-
284289
def r = sh(label: "[${integrationName}] git-diff: check non-package files", script: "git diff --name-only \$(git merge-base ${from} ${to}) ${to} | egrep -v '^(packages/|.github/CODEOWNERS)'", returnStatus: true)
285290
if (r == 0) {
286291
echo "[${integrationName}] PR is affected: found non-package files"

0 commit comments

Comments
 (0)