title: Jenkins cant find Pull request ref specs from TFS Git Repository to build pr-merges
body: <p>I am trying to automate Jenkins (atm. 2.60.3, Team Foundation Server Plug-in
  5.121.0, git plugin 3.5.1, git client plugin 2.5.0) together with a TFS (15.117.26714.0)</p>
  
  <p>"Enable Push trigger for all jobs / team status for all jobs" is present in the Jenkins configuration, the soap api connection does work when using the Test connection button.</p>
  
  <p>I have a Multibranch pipeline project configured with a git repository on that TFS server; my main problem is, that pull requests are not found when scanning the refspecs; the refspecs in my Multibranch pipeline Project are:</p>
  
  <p>Ref Spec </p>
  
  <pre><code>+refs/heads/*:refs/remotes/@{remote}/*
  </code></pre>
  
  <p>and Ref Spec</p>
  
  <pre><code>+refs/pull/*:refs/remotes/@{remote}/pull/*
  </code></pre>
  
  <p>we updated from TFS 2015 where, if i recall correctly, the refspecs were</p>
  
  <pre><code>+refs/pull/*:refs/remotes/@{remote}/pr/*
  </code></pre>
  
  <p>and with the old 2015 TFS it was possible to find the pr/ refs and get the multibranch job like </p>
  
  <pre><code>&lt;JENKINSHOST&gt;:8080/job/MultibranchJob/job/pr%252f&lt;PRID&gt;
  </code></pre>
  
  <ul>
  <li>although this was a few months back, and I also have updated the LTS version of Jenkins and all the plugins.</li>
  </ul>
  
  <p>This in turn would be started to verify if the pull request which should be completed does not break the build. (As far as I know identifying pull requests is not yet implemented in the TFS plugin as in the bitbucket and github plugins)</p>
  
  <p>neither @{remote}/pr/* nor @{remote}/pull/* seem to find the refspecs.
  The Jenkins Host has an own compiled git version 2.13.3, because the Centos 7 git was too old to communicate properly with TFS 2017.</p>
  
  <p>But the pull request ref specs are nowhere to be found:</p>
  
  <pre><code>Started by user Jenkins admin
  [Tue Aug 29 12:49:03 CEST 2017] Starting branch indexing...
   &gt; git rev-parse --is-inside-work-tree # timeout=10
  Setting origin to MYOWNTFSGITREPO
   &gt; git config remote.origin.url MYOWNTFSGITREPO # timeout=10
  Fetching origin...
  Fetching upstream changes from origin
   &gt; git --version # timeout=10
  using GIT_ASKPASS to set credentials 
   &gt; git fetch --tags --progress origin +refs/pull/*:refs/remotes/origin/pull/* +refs/heads/*:refs/remotes/origin/* 
  using GIT_ASKPASS to set credentials 
   &gt; git ls-remote --symref MYOWNTFSGITREPO # timeout=10
  using GIT_ASKPASS to set credentials 
   &gt; git ls-remote MYOWNTFSGITREPO # timeout=10
   &gt; git rev-parse --is-inside-work-tree # timeout=10
  Setting origin to MYOWNTFSGITREPO
   &gt; git config remote.origin.url MYOWNTFSGITREPO # timeout=10
  Fetching &amp; pruning origin...
  Fetching upstream changes from origin
   &gt; git --version # timeout=10
  using GIT_ASKPASS to set credentials 
   &gt; git fetch --tags --progress origin +refs/pull/*:refs/remotes/origin/pull/* +refs/heads/*:refs/remotes/origin/*  --prune
  Listing remote references...
   &gt; git config --get remote.origin.url # timeout=10
  using GIT_ASKPASS to set credentials 
   &gt; git ls-remote -h MYOWNTFSGITREPO # timeout=10
  Checking branches...
    Checking branch develop
        ‘Jenkinsfile’ found
      Met criteria
  Changes detected: develop (51e43e3456f49506086ad5649282695d9f0eff7d → 6008de4da7d017b35cb73cf28963057b8512584c)
  Did not schedule build for branch: develop
    Checking branch master
        ‘Jenkinsfile’ found
      Met criteria
  Changes detected: master (5c2f4df13a6cf53700ff1562d5347c31ff2a8d69 → b856b96743870bc80d9523c79922b01bfe0f363b)
  Did not schedule build for branch: master
    Checking branch feature/myFeature
        ‘Jenkinsfile’ found
      Met criteria
  No changes detected: feature/myFeature (still at 72fa143c6cbf4cf492129ad43f9a0053d5edf785)
  Processed 3 branches
  [Tue Aug 29 12:49:03 CEST 2017] Finished branch indexing. Indexing took 0.57 sec
  Finished: SUCCESS
  </code></pre>
  
  <p>although if i use git ls-remote from my dev-pc:</p>
  
  <pre><code>$ git ls-remote
  From MYOWNTFSGITREPO
  b856b96743870bc80d9523c79922b01bfe0f363b        HEAD
  6008de4da7d017b35cb73cf28963057b8512584c        refs/heads/develop
  72fa143c6cbf4cf492129ad43f9a0053d5edf785        refs/heads/feature/myFeature
  b856b96743870bc80d9523c79922b01bfe0f363b        refs/heads/master
  d6998b37fb29dc5eb6eaac812b8af58e8f31d402        refs/pull/26/merge
  </code></pre>
  
  <p>is it possible that the --prune removes the merge because it could probably not be reachable? But that merge should have parents in both branches that are used for the pull request, right? </p>
  
  <p>Am I missing something painfully obvious?</p>
  
  <p>The scanning of the repo works, else all the other branches could not been found.</p>
  
  <p>I know making own branch for the pull request is somewhat hacky, although it did work to verify that the merged code works. If there is a better way to implement the testing with a multibranch project I am absolutely open for a different approach.</p>
  
  <p>edit: </p>
  
  <p>trying on my dev-pc all the commands from the log above; the last </p>
  
  <pre><code>git ls-remote -h MYOWNTFSREPO
  </code></pre>
  
  <p>limits to only heads, is there any possibility to circumvent that?
  git ls-remote MYOWNTFSREPO would also give me /refs/pull//merge, which would be exactly what I want to start the building of the Pr merge commits.</p>