Skip to content

Commit 7f1447b

Browse files
committed
WIP adding merge base to teamcity pr job
1 parent fef6f8d commit 7f1447b

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

.ci/teamcity/setup_ci_stats.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const ciStats = require('./ci_stats');
2424
branch: process.env.GIT_BRANCH.replace(/^(refs\/heads\/|origin\/)/, ''),
2525
commit: process.env.GIT_COMMIT,
2626
targetBranch: process.env.GITHUB_PR_TARGET_BRANCH || null,
27-
mergeBase: null, // TODO
27+
mergeBase: process.env.GITHUB_PR_MERGE_BASE || null,
2828
});
2929
} catch (ex) {
3030
console.error(ex);

.ci/teamcity/setup_env.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ if is_pr; then
4040
tc_set_env ghprbGhRepository "elastic/kibana" # TODO?
4141
tc_set_env ghprbActualCommit "$GITHUB_PR_TRIGGERED_SHA"
4242
tc_set_env BUILD_URL "$TEAMCITY_BUILD_URL"
43+
44+
set_git_merge_base
4345
else
4446
tc_set_env ELASTIC_APM_ACTIVE "${CI_REPORTING_ENABLED-}"
4547
tc_set_env CHECKS_REPORTER_ACTIVE false

.ci/teamcity/util.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,10 @@ tc_retry() {
7979
}
8080
tc_end_block "Retryable Step - Attempt #1"
8181
}
82+
83+
set_git_merge_base() {
84+
if [[ "${GITHUB_PR_TARGET_BRANCH-}" ]]; then
85+
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
86+
tc_set_env GITHUB_PR_MERGE_BASE "$(git merge-base HEAD FETCH_HEAD)"
87+
fi
88+
}

0 commit comments

Comments
 (0)