Answers: <p>Usually you want to test your code as closely as possible to how it's going to be deployed.  This means you're going to want to run your tests against code that's been merged with master, so choose the first option (merge first, then test).  There's no point in the 2nd option if you're never going to deploy the code in that state (i.e. unmerged).</p>
  
  <p>Or for another perspective: good CI practices involve merging soon and merging often.  This would naturally lead one to the first option.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-06-29T16:22:10.533Z
Answers: 2018-06-29T16:22:10.533Z
Answers: jayhendren
Body: <p>I'm using Jenkins Pipeline with Github for our CI purposes and I'm trying to think what the strategy should be for what is checked out to run. </p>
  
  <p>Jenkins provides three options when discovering pull requests:</p>
  
  <pre><code> 1. Merging the pull request with the current target branch revision
   2. The current pull request revision
   3. Both the current pull request revision and the pull request merged with the current target branch.
  </code></pre>
  
  <p>I'm looking for opinions on what others choose. To run just the branch head because then it's clear exactly what is being run, or to run the merge state because then it makes you more confident when you merge. </p>
  
  <p>Currently, I'm using just the PR branch HEAD and enabled Github to require a master merge if the branch is out of date. </p>
  
Tags: <jenkins><continuous-integration><jenkins-pipeline><github>
Title: Should I run CI on merge state or HEAD of branch in a PR?
UserDisplayName: Ilya
ThreadText: # Should I run CI on merge state or HEAD of branch in a PR?
  
  (Asked by: username_0 on 2018-06-28)
  
  I'm using Jenkins Pipeline with Github for our CI purposes and I'm trying to think what the strategy should be for what is checked out to run.
  
  Jenkins provides three options when discovering pull requests:
  
  ```
   1. Merging the pull request with the current target branch revision
   2. The current pull request revision
   3. Both the current pull request revision and the pull request merged with the current target branch.
  
  ```
  
  I'm looking for opinions on what others choose. To run just the branch head because then it's clear exactly what is being run, or to run the merge state because then it makes you more confident when you merge.
  
  Currently, I'm using just the PR branch HEAD and enabled Github to require a master merge if the branch is out of date.
  
  **Tags:** jenkins, continuous-integration, jenkins-pipeline, github
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-06-29. Score: 3 | Accepted answer
  
  Usually you want to test your code as closely as possible to how it's going to be deployed. This means you're going to want to run your tests against code that's been merged with master, so choose the first option (merge first, then test). There's no point in the 2nd option if you're never going to deploy the code in that state (i.e. unmerged).
  
  Or for another perspective: good CI practices involve merging soon and merging often. This would naturally lead one to the first option.
  
  
  ---
  
  