build(ci): baseline the Jenkins .claude/ filter on the PR target branch - #1850
Merged
Conversation
#1846 guarded the two JDK stages on a diff against GIT_PREVIOUS_SUCCESSFUL_COMMIT. On a branch build that is the right baseline. On a pull request build it is not: the pointer is the previous head of the same PR, so once the PR is rebased - or the target branch is merged into it - everything the target absorbed in between shows up as a change of the PR's own. PR-1848 build #2 is the case. The pull request touches only .claude/skills/releasing-struts/, but it had been rebased across the maven.yml fix, and Jenkins computed: + base=b633817af047afaa80948404e2e6f1eb78e02b7a + git diff --name-only b633817... HEAD + outside=.github/workflows/maven.yml Changes outside .claude/: true so both JDK stages ran a full Maven round trip for a documentation-only change. Since main almost always carries code, this made the filter useless for any pull request that is ever brought up to date. Use the merge base with the target branch as the baseline when CHANGE_TARGET is set. The multibranch checkout already fetches it - git fetch ... +refs/heads/main:refs/remotes/origin/main - so origin/$CHANGE_TARGET resolves in the workspace. Branch builds have no target and keep the previous-successful-commit baseline. Fail-open is unchanged and still covers the new path: an unresolvable merge base (target branch absent) yields an empty base and reports true. Exercised against the real commits of #1848 either side of its rebase, and against synthetic heads for: code only, .claude only, mixed, a .claudefoo/ near miss, a missing target branch, and the three branch build baselines. All ten behave as intended. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Follow-up to #1846 and #1849. The GitHub Actions side is fixed; Jenkins still ran a full Maven round trip on a docs-only PR.
What happens
#1846 guards the two JDK stages on a diff against
GIT_PREVIOUS_SUCCESSFUL_COMMIT. For a branch build that is the right baseline. For a PR build it is not — the pointer is the previous head of the same PR, so once the PR is rebased (or the target branch merged into it), everything the target absorbed in between looks like a change of the PR's own.PR-1848build #2 is the case. That PR touches only.claude/skills/releasing-struts/, but it had been rebased across the maven.yml fix, and Jenkins computed:Both JDK stages then ran in full for a documentation-only change. Since
mainalmost always carries code, this makes the filter useless for any PR that is ever brought up to date — which is most of them.The fix
Use the merge base with the target branch when
CHANGE_TARGETis set. The multibranch checkout already fetches it:so
origin/$CHANGE_TARGETresolves in the workspace. Branch builds have no target and keep the previous-successful-commit baseline, unchanged.Fail-open is preserved and now covers the new path too: an unresolvable merge base (target branch absent) leaves
baseempty and reportstrue.Verification
Ran the stage's shell logic against the real commits of #1848 either side of its rebase, and against synthetic heads off
main:58a9a013a)7411024c9trueb633817af)81b34c2957411024c9.claudeonly7411024c9.claude+ code7411024c9.claudefoo/near miss7411024c9origin/main7411024c9Not verifiable locally: that Jenkins exports
CHANGE_TARGETinto theshstep. It is a standard multibranch variable andGIT_PREVIOUS_SUCCESSFUL_COMMITreaches the same script the same way, so the risk is low — and if it were ever unset, the branch-build path takes over and behaviour is exactly today's. Worth a glance at theDetect changestrace on this PR's own build to confirm.Only the 7.x line is changed here;
support/struts-6-x-xcarries none of this.🤖 Generated with Claude Code