Change By: Ian Homer (06/Aug/14 11:16 AM)
Description: We recently upgraded our stash install including the stash jenkins webhook.   Now in this plugin [has recently started calling|https://github.com/Nerdwin15/stash-jenkins-postreceive-webhook/commit/d4c9709557504c72473210c413592827b5460f0f] the Jenkins git *notifyCommit* endpoint with *branches* and *sha1* query string parameters set in the URL, e.g. it now calls URLs like

/jenkins/git/notifyCommit?url="">
This looks valid according to the [Git plugin wiki|https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin].

It used to NOT set the branches and sha1 parameter, e.g. simply ...

/jenkins/git/notifyCommit?url="">
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


{code}
Started by an SCM change
Building on master in workspace /home/jenkins/jobs/My Job/workspace
> /usr/local/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/local/bin/git config remote.origin.url ssh://git@my-stash-host:7999/project/repository.git # timeout=10
Fetching upstream changes from ssh://git@my-stash-host:7999/project/repository.git
> /usr/local/bin/git --version # timeout=10
> /usr/local/bin/git fetch --tags --progress ssh://git@my-stash-host:7999/project/repository.git +refs/heads/*:refs/remotes/origin/*
Seen branch in repository origin/HEAD
Seen branch in repository origin/feature/XXXX-1018
Seen branch in repository origin/feature/XXXX-1093
...

Seen 293 remote branches
Checking out Revision b3dd6fe0a7db3b78739cf05c79a85bad56b3bc11 (origin/feature/XXXX-2571)
{code}

e.g. With SHA1 set

{code}
commit notification b3dd6fe0a7db3b78739cf05c79a85bad56b3bc11
Building on master in workspace /home/jenkins/jobs/My Job/workspace
> /usr/local/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/local/bin/git config remote.origin.url ssh://git@my-stash-host:7999/project/repository.git # timeout=10
Fetching upstream changes from ssh://git@my-stash-host:7999/project/repository.git
> /usr/local/bin/git --version # timeout=10
> /usr/local/bin/git fetch --tags --progress ssh://git@my-stash-host:7999/project/repository.git +refs/heads/*:refs/remotes/origin/*
> /usr/local/bin/git rev-parse b3dd6fe0a7db3b78739cf05c79a85bad56b3bc11^{commit} # timeout=10
Checking out Revision b3dd6fe0a7db3b78739cf05c79a85bad56b3bc11(detached)
{code}

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 (
how however  we don't benefit from the notifyCommit being explicit about the commit revision to build).

FYI - our Apache configuration workaround is:
{code}

RewriteEngine On

# Remove branches and sha1 from notify notifyCommit calls
RewriteCond %{QUERY_STRING} ^url="">RewriteRule ^ %{REQUEST_URI}?url="">{code}
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to