Why not to expose commit hash from SCM as an environment variable? #166
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.
I've started to use GitHub Branch Source plugin for my project. While developing my pipeline I was trying to set PR commit status for which I commit hash was needed. I was wondering if there any way to get it without
checkout
step. It didn't look too impossible - in Multibranch Pipelines and Organization Folders Jenkins "knows" from which commit has Jenkinsfile was taken. I've written the this https://gist.github.com/ababushk//930980d79ab09c74da34be459563f760 and added it to my Global Library. But it looks so "hacky" that I've started to search for a place where other environment variables likeCHANGE_ID
andBRANCH_NAME
are created. I've foundBranchNameContributor
class to which I've added variable that I desire so much.I'm completely new in Jenkins plugin development and Java in general, but I'm wondering why such simple thing as commit hash is not available by default.