Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Note: the <a href="https://stackoverflow.com/users/245777/milkplus">OP milkplus</a>'s comment refers to recent <a href="http://issues.hudson-ci.org/browse/HUDSON-6856" rel="nofollow noreferrer"><strong>Hudson bug 6856</strong></a> (June 2010), which mentions:</p> <blockquote> <p><strong>Git builds with detached head no matter what</strong></p> </blockquote> <p>While it is unclear if that particular issue will be solved (answers suggest it might actually "work as designed"!), it also refers to <a href="http://github.com/abayer/Hudson-GIT-plugin/tree/HUDSON-6856" rel="nofollow noreferrer">this version of hudson Git Plugin</a>, allowing to checkout a local branch.</p> <hr> <p>You are in a <strong><a href="https://stackoverflow.com/questions/999907/git-push-says-everything-up-to-date-even-though-i-have-local-changes/1000009#1000009"><code>DETACHED HEAD</code></a></strong> because, as the git plugin is working right now, it did checkout directly a commit SHA1, and not a branch <code>HEAD</code>.</p> <blockquote> <p>The state you are in while your <code>HEAD</code> is detached is not recorded by any branch (which is natural --- you are not on any branch). What this means is that you can discard your temporary commits and merges by switching back to an existing branch.</p> </blockquote> <p>Your building script could first try to <a href="https://stackoverflow.com/questions/2706797/git-finding-what-branch-a-commit-came-from">find what branch the relevant commit is coming from</a>.</p> <hr> <p>As the OP <a href="https://stackoverflow.com/users/245777/milkplus">milkplus</a> realized by looking at the <a href="http://github.com/hudson/Hudson-GIT-plugin/blob/master/src/main/java/hudson/plugins/git/GitSCM.java" rel="nofollow noreferrer">source code of the Hudson Git Plugin</a>:</p> <pre><code>public void buildEnvVars(AbstractBuild build, java.util.Map&lt;String, String&gt; env) { super.buildEnvVars(build, env); String branch = getSingleBranch(build); if(branch != null){ env.put(GIT_BRANCH, branch); } } </code></pre> <p>An environment variable <code>GIT_BRANCH</code> is set, but it doesn't appear to have any value in the xml build script:</p> <pre><code>&lt;property environment="env"/&gt; &lt;echo&gt;GIT_BRANCH = ${env.GIT_BRANCH}&lt;/echo&gt; </code></pre> <p>If that is the case, it may be because of <a href="http://issues.hudson-ci.org/browse/HUDSON-7554" rel="nofollow noreferrer">issue 7554</a>:</p> <blockquote> <p><code>GIT_BRANCH</code> not set when multiple branches are selected for build </p> <blockquote> <blockquote> <p>When trying to identify what branch the current build are on, I found that the <code>GIT_BRANCH</code> environment variable is not set when more then a single branch is selected to be built.</p> </blockquote> <p>This isn't really a bug so much as a feature request, I think - the <code>GIT_BRANCH</code> env var is only set if there's a single branch, so as such, it's not relevant if/when there are multiple branches. I'm not sure how we'd format an env var for multiple branches in this context.</p> </blockquote> <p>I thought that <code>GIT_BRANCH</code> shall be set to the branch that is currently building. Like if the build is on master it will contain the master.</p> <p>That would help to for example push to another remote that branch that was built during this build. Or Triggering another Build with the correct branch set to be built.</p> </blockquote> <p>Kind of mirror the <a href="http://evgenyg.wordpress.com/2010/03/27/hudson-git-maven/" rel="nofollow noreferrer">NPE described here</a></p> <p><img src="https://i.stack.imgur.com/TkYCQ.png" alt="alt text"></p> <blockquote> <p>For some reason Git plugin started to pass null value for <code>GIT_BRANCH</code> environment variable.<br> This caused Maven plugin to fail in <code>System.getProperties().putAll(systemProps)</code> call.</p> <p>The solution was to use "<code>master</code>" as default Git branch instead of "<code>**</code>" or empty String.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload