Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49786

Jenkins uses the same directory for Jenkinsfile pull and project workspace, branches are mixed up

XMLWordPrintable

      Jenkins 2.89.3
      Git client plugin 2.7.1
      Git plugin 3.8.0
      Pipeline 2.5


      Create pipeline from SCM, use wrong as local branch name.

      Jenkinsfile:

      pipeline {
          agent any
      
          stages {
              stage ('SCM') {
                  steps {
                      script {
                          echo '1'
                          bat script: 'git remote -v'
                          bat script: 'git branch'
      
                          checkout([$class: 'GitSCM', branches: [[name: 'develop']],
                              extensions: [[$class: 'LocalBranch', localBranch: 'expected']],
                              //extensions: [[$class: 'LocalBranch', localBranch: 'expected'], [$class: 'WipeWorkspace']],
                              userRemoteConfigs: [[url: 'ssh://gitblit.example.com/anton/jenkins-project.git',
                                  credentialsId: 'jenkins-ssh-credential']]])
      
                          echo '2'
                          bat script: 'git remote -v'
                          bat script: 'git branch'
                      }
                  }
              }
          }
      }

      First build (Log1.txt)

      Branches after Jenkinsfile checkout:

      * wrong
      

      Branches after project repo checkout:

      * expected
        wrong
      

      An unexpected branch wrong exists in the list.

      Second build (Log2.txt)

      Branches after Jenkinsfile checkout:

        expected
      * wrong
      

      An unexpected branch expected exists in the list.

      Branches after project repo checkout:

      * expected
        wrong
      

      An unexpected branch wrong exists in the list.

      Build with WipeWorkspace extension (LogWipe.txt)

      Branches after Jenkinsfile checkout:

      * wrong
      
      * expected
      

      Everything is good, but I don't need to clone the repository every time.

      PruneStaleBranch extension does not help (I guess it deletes only tracked branches).


      1. Why does Jenkins use my workspace to checkout Jenkisfile? I expect it to use a temp dir, like libLoader does.
      2. Why does it mix branches for unrelated repositories? Does it manually change .git/ content somehow?

      Similar issue: JENKINS-30619

        1. 2018-02-28_1145.png
          2018-02-28_1145.png
          51 kB
        2. Log1.txt
          5 kB
        3. Log2.txt
          4 kB
        4. LogWipe.txt
          5 kB

            Unassigned Unassigned
            antonzimin Anton Zimin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: