title: Git + Jenkins Builds from hooks - remote branches across multiple servers
body: <p>I'm not 100% sure what best practice is in my situation and whether I have the hooks set up in the wrong place.</p>
  
  <p>My architecture/workflow is as follows (simplified):</p>
  
  <pre><code>Git Repos - //SERVER-NAME/e$/repositories/PROJECT-NAME
  </code></pre>
  
  <p>I then have two remote branches on their own servers:</p>
  
  <pre><code>DEV - //DEV-SERVER/e$/projects/PROJECT-NAME
  UAT - //UAT-SERVER/e$/projects/PROJECT-NAME
  </code></pre>
  
  <p>So, let's assume work is done directly on the DEV server. when done and committed, I want that commit to trigger a build from the DEV branch on the same server (Jenkins is running on the DEV and UAT servers).</p>
  
  <p>In the Configure section of jenkins, I have the Git Repos URL above in the 'Repository URL' section and 'DEV' in the 'Branches to build'.</p>
  
  <p>in the checked out/cloned DEV branch, I have a post-commit hook with the following content:</p>
  
  <pre><code>#!/bin/sh
  curl http://localhost:8080/job/PROJECT-NAME/build?delay=0sec
  </code></pre>
  
  <p>However, this is presumably checking out/cloning the remote DEV branch which has not yet received the committed changes? I then tried changing the hook to 'post-receive' thinking this would be triggered after a </p>
  
  <pre><code>git push origin DEV
  </code></pre>
  
  <p>but this didn't trigger.</p>
  
  <p>I then thought that the hook might need to sit within the actual remote repositories' hooks directory, but I'm not sure if A) this is correct and if so B) what the hook should contain - presumably a URL that kicks off the build on the DEV server? </p>
  
  <p>Bit confused ...</p>
  
  <p>Also, I'd like the same to work on the UAT server. I'd like the workflow to be </p>
  
  <ol>
  <li>Commit on DEV </li>
  <li>Triggers a build on DEV (incl unit tests etc)</li>
  <li>Merge DEV with UAT </li>
  <li>Triggers a build on UAT </li>
  <li>Merge UAT with master</li>
  <li>Tag created and released to live.</li>
  </ol>
  
  <p>I'm not sure if the above workflow would be better as only running the build on the UAT server upon a git merge into master (but BEFORE it merges, only merging on successful build) ?</p>
  
  <p>Thanks ..</p>