We recently upgraded our stash install including the stash jenkins webhook. Now this plugin has recently started calling the Jenkins git notifyCommit endpoint with branches and sha1 query string parameters set in the URL, e.g. it now calls URLs like
This looks valid according to the Git plugin wiki.
It used to NOT set the branches and sha1 parameter, e.g. simply ...
Since this webhook started calling this endpoint with the sha1 parameter our Jenkins jobs has started setting the GIT_BRANCH variable to detached and not the appropriate branch name.
Without this sha1 parameter the job output starts with "Started by an SCM change". With this sha1 parameter the job output starts with e.g. "commit notification b3dd6fe0a7db3b78739cf05c79a85bad56b3bc11".
e.g. Without SHA1 set we see
e.g. With SHA1 set
Note that Checking out Revision line knows the branch (AND sets GIT_BRANCH variable to the correct branch name) without SHA1 set but it does not know the branch, i.e. it sets detached for the branch name (AND sets GIT_BRANCH to detached).
Note we have implemented a work around in apache by removing the sha1 parameter from the URL which fixes this for our environment (however we don't benefit from the notifyCommit being explicit about the commit revision to build).
FYI - our Apache configuration workaround is: