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

GIT_LOCAL_BRANCH var is not setting when we enabled for "check out to matching local branch" via declarative pipeline

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • None
    • Jenkins 2.440.3

      When we enabled "Check out to matching local branch" in the Jenkins UI, it worked fine, and we could see that the "GIT_LOCAL_BRANCH" variable was getting the appropriate branch value. However, when we tried to enable it in the code using a declarative pipeline, we did not see the "GIT_LOCAL_BRANCH" variable. Below is the snippet of code we are using. Could you please have a look and help me out with this?

       

      Code Snippet:-

      checkout([
      $class: 'GitSCM',
      branches: scm.branches, // Jenkins job should add "Discover branches" and "Discover tags" to "Behaviors" subsection within the "Branch Sources" section
      extensions: [
      pruneTags(true), // Prune stale tags
      [$class: 'CloneOption', noTags: false], // Fetch tags
      [$class: 'LocalBranch', localBranch: "**"], // evaluate branch name
      [$class: 'PruneStaleBranch'], // Prune stale branches
      [$class: 'WipeWorkspace'] // Wipe out the workspace before cloning to ensure it is clean
      ],
      userRemoteConfigs: scm.userRemoteConfigs
      ])

       

       

            Unassigned Unassigned
            venky2291 Pasupula
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: