Fix Jenkins GIT_REF for pull_request Actions - #131
Merged
Conversation
github.sha on pull_request is refs/pull/N/merge, which Jenkins never fetches (heads only). That produced "Couldn't find any revision to build." Push to main is unchanged.
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.
The GitHub Action was passing `github.sha` to Jenkins `GIT_REF`.
On push that SHA is on `main` and Jenkins finds it. On pull_request it is GitHub’s hidden merge commit (`refs/pull/N/merge`). Jenkins only fetches `refs/heads/*`, so checkout fails with:
`Couldn't find any revision to build`
This switches `GIT_REF` to `github.event.pull_request.head.sha` for PRs (the commit on the PR branch) and keeps `github.sha` for push.
Your Jenkins pipeline and its parameter defaults are fine. This is only the value the Action sends.