Skip to content

Fix Jenkins GIT_REF for pull_request Actions - #131

Merged
mattcasters merged 2 commits into
mainfrom
fix/jenkins-git-ref-pr-head
Aug 22, 2026
Merged

Fix Jenkins GIT_REF for pull_request Actions#131
mattcasters merged 2 commits into
mainfrom
fix/jenkins-git-ref-pr-head

Conversation

@mattcasters

Copy link
Copy Markdown
Collaborator

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.

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.
@mattcasters
mattcasters deployed to jenkins-data-hopper August 22, 2026 21:06 — with GitHub Actions Active
@mattcasters
mattcasters deployed to jenkins-data-hopper August 22, 2026 21:06 — with GitHub Actions Active
@mattcasters
mattcasters merged commit efb00c4 into main Aug 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant