title: Jenkins pipelines from SCM in different branch not working
body: <p>I'm working with pipelines in Jenkins in a environment which already has configured a pipeline script from SCM which then uses a groovy file for the stages/jobs inside the pipeline. This scripts are on Bitbucket in a master branch. </p>
  
  <p>Every time jenkins jobs starts it call master branch and it runs with no problem and the stages of the pipeline are run.</p>
  
  <p>Now I created a new branch on bitbucket and modified the groovy file to include some more steps (like running unit tests and some more stuff) and I would like that jenkins runs that script but with the branch I specified (the one I created). </p>
  
  <p>Thing is that eventhough I specified my branch in in "branch specifier",  jenkins still runs the master branch. Here are some images of what I have configured.<br>
  How can I specify the branch  I want to be run on the pipeline script from SCM?</p>
  
  <p><a href="https://i.stack.imgur.com/eedyD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eedyD.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/5qA8M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5qA8M.png" alt="enter image description here"></a></p>
  
  <pre><code>Lightweight checkout support not available, falling back to full checkout.
  Checking out git git@bitbucket.xxxxxx/xxxxxx.git into /data/jobs/extractor-pipeline-test-dev/workspace@script to read extractor-dev/Jenkinsfile
  Cloning the remote Git repository
  Cloning repository git@bitbucket.org:xxxxxx/xxxxxxxxxx.git
   &gt; /usr/bin/git init /data/jobs/extractor-pipeline-test-dev/workspace@script # timeout=10
  Fetching upstream changes from git@bitbucket.org:xxxx/xxxxxx.git
   &gt; /usr/bin/git --version # timeout=10
   &gt; /usr/bin/git fetch --tags --progress git@bitbucket.org:xxxxxx/deploy.git +refs/heads/*:refs/remotes/origin/*
   &gt; /usr/bin/git config remote.origin.url git@bitbucket.org:xxxxx/deploy.git # timeout=10
   &gt; /usr/bin/git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
   &gt; /usr/bin/git config remote.origin.url git@bitbucket.org:xxxxxxx/deploy.git # timeout=10
  Fetching upstream changes from git@bitbucket.org:xxxxx/deploy.git
   &gt; /usr/bin/git fetch --tags --progress git@bitbucket.org:grydev/gp_deploy.git +refs/heads/*:refs/remotes/origin/*
  **Seen branch in repository origin/DEVOPS-568-pipeline-ci
  Seen branch in repository origin/dev
  Seen branch in repository origin/master**
  Seen 3 remote branches
   &gt; /usr/bin/git tag -l # timeout=10
  Checking out Revision e3270789a8181b26464f878bfccdf39b3fdabcb0 (master)
  Commit message: " ....."
   &gt; /usr/bin/git config core.sparsecheckout # timeout=10
   &gt; /usr/bin/git checkout -f e3270789a8181b26464f878bfccdf39b3fdabcb0
   &gt; /usr/bin/git rev-list e3270789a8181b26464f878bfccdf39b3fdabcb0 # timeout=10
  </code></pre>
  
  <p>This is the groovy file, but groovy files  does steps of the code that will be deployed. It doesn't  run any jenkin script. Where it says "master" is of maser code to be deploy and not the deploy script. </p>
  
  <p>Groovy file:</p>
  
  <pre><code>def call(body) {
  
      def config = [:]
      body.resolveStrategy = Closure.DELEGATE_FIRST
      body.delegate = config
      body()
  
      def artifactName = 'imp'
      def artifactExt = '.war'
      def artifactVersion = '0.0.1'
  
      def buildPath = 'target/'
      def warFile = artifactName + '-' + artifactVersion + artifactExt
      def warPath = buildPath + warFile
      def warNoVersion = artifactName + artifactExt
  
      def deployPath = '/var/lib/tomcat8/webapps/'
      def deployFile = deployPath + warNoVersion
  
      node {
          // Clean workspace before doing anything
          //deleteDir()
  
          try {
  
              stage ('Code Checkout') {
                  git branch: 'master',
                      credentialsId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
                      url: 'ssh://git@bitbucket.org/xxxxx/xxxximporter'
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/9EWQT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9EWQT.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/aIMBj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aIMBj.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/02IO2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/02IO2.jpg" alt="enter image description here"></a></p>