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

GitParameter not cleaning up stale ref branch

    • Declarative backlog

      But I don't like manual work as this issue kept coming once in a while. I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!

      Summary

      I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using git-parameter:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy. I'm using GitHub as my code repository as well.

      @Library("myCiCdLib")
      properties([
          steps.parameters([
              gitParameter(
                    branch: '',
                    branchFilter: 'origin/(release/.*)',
                    defaultValue: 'master',
                    description: 'Git branch to deploy',
                    name: 'BRANCH',
                    quickFilterEnabled: false,
                    selectedValue: 'NONE',
                    sortMode: 'DESCENDING',
                    type: 'PT_BRANCH'
                  ),
          ])
      ])
      
      pipeline {
      
        stages {
           stage("Build"){
              make build
              echo "Whatever steps ..."
           }
           # ... the rest of the pipeline
        }
      }

      The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called feature-abc in origin a week ago and when the Pull Request from that branch got merged a week ago, GitHub automatically deleted the feature-abc branch in origin repository.

      Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called

      • feature-abc /navbar 
      • feature-abc/menu .

      Notice the name has same prefix with branch feature-abc .

      The issue:

      error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
      cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
      
      ! [new branch] feature-abc/navbar -> origin/feature-abc/navbar (unable to update local ref) 
         error: cannot lock ref 'refs/remotes/origin/feature-abc/navbar': 'refs/remotes/origin/feature-abc' exists; 
         cannot create 'refs/remotes/origin/feature-abc/navbar'
      
      ! [new branch] feature-abc/menubar -> origin/feature-abc/menubar (unable to update local ref)
         error: cannot lock ref 'refs/remotes/origin/feature-abc/menubar': 'refs/remotes/origin/feature-abc' exists; 
         cannot create 'refs/remotes/origin/feature-abc/menubar'

       

      The solution I know is by running the following in the jenkins master server node.

      git fetch --prune origin

      But I don't like manual work as this issue kept coming once in a while. I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!

          [JENKINS-71512] GitParameter not cleaning up stale ref branch

          Dan created issue -
          Dan made changes -
          Description Original: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter


          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged, we deleted the branch in origin.

           

           

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called +{{feature-abc}}+ {{+/navbar+ and ++ {+}feature-abc{+}{+}/menu{+}}} Notice the name has same prefix with branch +{{feature-abc}}+ .
          h4. The issue:

           
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
          ! [new branch] HU-8248/enable_ima -> origin/feature-abc/menu (unable to update local ref) error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc/feature-abc' exists; cannot create 'refs/remotes/origin/feature-abc/navbar'
          ! [new branch] HU-8248/nav -> origin/feature-abc/menu (unable to update local ref)
          {code}
           

           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

           

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          New: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged, we deleted the branch in origin.

           

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called +{{feature-abc}}+ {{+/navbar+ }}and{{ {+}feature-abc{+}{+}/menu{+}}} . Notice the name has same prefix with branch +{{feature-abc}}+ .
          h4. The issue:

           
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
          ! [new branch] HU-8248/enable_ima -> origin/feature-abc/menu (unable to update local ref) error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc/feature-abc' exists; cannot create 'refs/remotes/origin/feature-abc/navbar'
          ! [new branch] HU-8248/nav -> origin/feature-abc/menu (unable to update local ref)
          {code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

           

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          Dan made changes -
          Description Original: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged, we deleted the branch in origin.

           

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called +{{feature-abc}}+ {{+/navbar+ }}and{{ {+}feature-abc{+}{+}/menu{+}}} . Notice the name has same prefix with branch +{{feature-abc}}+ .
          h4. The issue:

           
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
          ! [new branch] HU-8248/enable_ima -> origin/feature-abc/menu (unable to update local ref) error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc/feature-abc' exists; cannot create 'refs/remotes/origin/feature-abc/navbar'
          ! [new branch] HU-8248/nav -> origin/feature-abc/menu (unable to update local ref)
          {code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

           

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          New: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged, we deleted the branch in origin.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called +{{feature-abc}}+ {{+/navbar+ }}and{{ {+}feature-abc{+}{+}/menu{+}}} . Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
          ! [new branch] HU-8248/enable_ima -> origin/feature-abc/menu (unable to update local ref) error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc/feature-abc' exists; cannot create 'refs/remotes/origin/feature-abc/navbar'
          ! [new branch] HU-8248/nav -> origin/feature-abc/menu (unable to update local ref)
          {code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

           

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          Dan made changes -
          Description Original: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged, we deleted the branch in origin.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called +{{feature-abc}}+ {{+/navbar+ }}and{{ {+}feature-abc{+}{+}/menu{+}}} . Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
          ! [new branch] HU-8248/enable_ima -> origin/feature-abc/menu (unable to update local ref) error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc/feature-abc' exists; cannot create 'refs/remotes/origin/feature-abc/navbar'
          ! [new branch] HU-8248/nav -> origin/feature-abc/menu (unable to update local ref)
          {code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

           

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          New: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged, we *deleted* the {{+feature-abc+}} branch in origin.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
          ! [new branch] HU-8248/enable_ima -> origin/feature-abc/menu (unable to update local ref) error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc/feature-abc' exists; cannot create 'refs/remotes/origin/feature-abc/navbar'
          ! [new branch] HU-8248/nav -> origin/feature-abc/menu (unable to update local ref)
          {code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          Dan made changes -
          Description Original: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged, we *deleted* the {{+feature-abc+}} branch in origin.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
          ! [new branch] HU-8248/enable_ima -> origin/feature-abc/menu (unable to update local ref) error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc/feature-abc' exists; cannot create 'refs/remotes/origin/feature-abc/navbar'
          ! [new branch] HU-8248/nav -> origin/feature-abc/menu (unable to update local ref)
          {code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          New: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using [git-parameter|https://jenkins.dev.arbo.works/manage/pluginManager/installed#:~:text=Git%20Parameter%20Plug,0.9.18]:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy.
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged, we *deleted* the {{+feature-abc+}} branch in origin.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
          ! [new branch] HU-8248/enable_ima -> origin/feature-abc/menu (unable to update local ref) error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc/feature-abc' exists; cannot create 'refs/remotes/origin/feature-abc/navbar'
          ! [new branch] HU-8248/nav -> origin/feature-abc/menu (unable to update local ref)
          {code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          Dan made changes -
          Assignee Original: Parichay Barpanda [ baymac ] New: Boguslaw Klimas [ klimas7 ]
          Dan made changes -
          Description Original: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using [git-parameter|https://jenkins.dev.arbo.works/manage/pluginManager/installed#:~:text=Git%20Parameter%20Plug,0.9.18]:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy.
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged, we *deleted* the {{+feature-abc+}} branch in origin.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
          ! [new branch] HU-8248/enable_ima -> origin/feature-abc/menu (unable to update local ref) error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc/feature-abc' exists; cannot create 'refs/remotes/origin/feature-abc/navbar'
          ! [new branch] HU-8248/nav -> origin/feature-abc/menu (unable to update local ref)
          {code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          New: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using [git-parameter|https://jenkins.dev.arbo.works/manage/pluginManager/installed#:~:text=Git%20Parameter%20Plug,0.9.18]:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy. I'm using *GitHub* as my code repository as well.
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged a week ago, GitHub automatically *deleted* the {{+feature-abc+}} branch in origin repository.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
          ! [new branch] HU-8248/enable_ima -> origin/feature-abc/menu (unable to update local ref) error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc/feature-abc' exists; cannot create 'refs/remotes/origin/feature-abc/navbar'
          ! [new branch] HU-8248/nav -> origin/feature-abc/menu (unable to update local ref)
          {code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          Dan made changes -
          Description Original: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using [git-parameter|https://jenkins.dev.arbo.works/manage/pluginManager/installed#:~:text=Git%20Parameter%20Plug,0.9.18]:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy. I'm using *GitHub* as my code repository as well.
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged a week ago, GitHub automatically *deleted* the {{+feature-abc+}} branch in origin repository.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp
          ! [new branch] HU-8248/enable_ima -> origin/feature-abc/menu (unable to update local ref) error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc/feature-abc' exists; cannot create 'refs/remotes/origin/feature-abc/navbar'
          ! [new branch] HU-8248/nav -> origin/feature-abc/menu (unable to update local ref)
          {code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          New: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using [git-parameter|https://jenkins.dev.arbo.works/manage/pluginManager/installed#:~:text=Git%20Parameter%20Plug,0.9.18]:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy. I'm using *GitHub* as my code repository as well.
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged a week ago, GitHub automatically *deleted* the {{+feature-abc+}} branch in origin repository.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp

          ! [new branch] feature-abc/navbar -> origin/feature-abc/navbar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/navbar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/navbar'

          ! [new branch] feature-abc/menubar -> origin/feature-abc/menubar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/menubar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/menubar'{code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          Dan made changes -
          Description Original: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using [git-parameter|https://jenkins.dev.arbo.works/manage/pluginManager/installed#:~:text=Git%20Parameter%20Plug,0.9.18]:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy. I'm using *GitHub* as my code repository as well.
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged a week ago, GitHub automatically *deleted* the {{+feature-abc+}} branch in origin repository.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp

          ! [new branch] feature-abc/navbar -> origin/feature-abc/navbar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/navbar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/navbar'

          ! [new branch] feature-abc/menubar -> origin/feature-abc/menubar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/menubar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/menubar'{code}
           

          The solution I know is by running `{{{}git fetch --prune origin{}}}` in the jenkins master server node. But I don't like manual work as this issue kept coming once in a while.

          I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          New: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using [git-parameter|https://jenkins.dev.arbo.works/manage/pluginManager/installed#:~:text=Git%20Parameter%20Plug,0.9.18]:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy. I'm using *GitHub* as my code repository as well.
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged a week ago, GitHub automatically *deleted* the {{+feature-abc+}} branch in origin repository.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp

          ! [new branch] feature-abc/navbar -> origin/feature-abc/navbar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/navbar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/navbar'

          ! [new branch] feature-abc/menubar -> origin/feature-abc/menubar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/menubar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/menubar'{code}
           

          The solution I know is by running the following in the jenkins master server node.
          {code:java}
          git fetch --prune origin{code}
           
          h4. But I don't like manual work as this issue kept coming once in a while. I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          Dan made changes -
          Description Original: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using [git-parameter|https://jenkins.dev.arbo.works/manage/pluginManager/installed#:~:text=Git%20Parameter%20Plug,0.9.18]:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy. I'm using *GitHub* as my code repository as well.
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged a week ago, GitHub automatically *deleted* the {{+feature-abc+}} branch in origin repository.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp

          ! [new branch] feature-abc/navbar -> origin/feature-abc/navbar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/navbar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/navbar'

          ! [new branch] feature-abc/menubar -> origin/feature-abc/menubar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/menubar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/menubar'{code}
           

          The solution I know is by running the following in the jenkins master server node.
          {code:java}
          git fetch --prune origin{code}
           
          h4. But I don't like manual work as this issue kept coming once in a while. I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!
          New: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using [git-parameter|https://jenkins.dev.arbo.works/manage/pluginManager/installed#:~:text=Git%20Parameter%20Plug,0.9.18]:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy. I'm using *GitHub* as my code repository as well.
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged a week ago, GitHub automatically *deleted* the {{+feature-abc+}} branch in origin repository.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp

          ! [new branch] feature-abc/navbar -> origin/feature-abc/navbar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/navbar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/navbar'

          ! [new branch] feature-abc/menubar -> origin/feature-abc/menubar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/menubar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/menubar'{code}
           

          The solution I know is by running the following in the jenkins master server node.
          {code:java}
          git fetch --prune origin{code}
           
          h3. {color:#4c9aff}But I don't like manual work as this issue kept coming once in a while. I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!{color}
          Dan made changes -
          Description Original: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using [git-parameter|https://jenkins.dev.arbo.works/manage/pluginManager/installed#:~:text=Git%20Parameter%20Plug,0.9.18]:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy. I'm using *GitHub* as my code repository as well.
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged a week ago, GitHub automatically *deleted* the {{+feature-abc+}} branch in origin repository.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp

          ! [new branch] feature-abc/navbar -> origin/feature-abc/navbar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/navbar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/navbar'

          ! [new branch] feature-abc/menubar -> origin/feature-abc/menubar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/menubar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/menubar'{code}
           

          The solution I know is by running the following in the jenkins master server node.
          {code:java}
          git fetch --prune origin{code}
           
          h3. {color:#4c9aff}But I don't like manual work as this issue kept coming once in a while. I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!{color}
          New: I have issue with Git. This is the issue in my Jenkins server when using gitParameter parameter. I'm using [git-parameter|https://jenkins.dev.arbo.works/manage/pluginManager/installed#:~:text=Git%20Parameter%20Plug,0.9.18]:0.9.18 plugin in my Pipeline input parameters where the pipeline user can choose the release branch they want to build and deploy. I'm using *GitHub* as my code repository as well.
          {code:java}
          @Library("myCiCdLib")
          properties([
              steps.parameters([
                  gitParameter(
                        branch: '',
                        branchFilter: 'origin/(release/.*)',
                        defaultValue: 'master',
                        description: 'Git branch to deploy',
                        name: 'BRANCH',
                        quickFilterEnabled: false,
                        selectedValue: 'NONE',
                        sortMode: 'DESCENDING',
                        type: 'PT_BRANCH'
                      ),
              ])
          ])

          pipeline {

            stages {
               stage("Build"){
                  make build
                  echo "Whatever steps ..."
               }
               # ... the rest of the pipeline
            }
          }{code}
          The problem may or may not related to Jenkins or the git plugins. But what happen is we have a branch called +{{feature-abc}}+ in origin a week ago and when the Pull Request from that branch got merged a week ago, GitHub automatically *deleted* the {{+feature-abc+}} branch in origin repository.

          Jenkins might also have pulled this branch into its workspace and run the pipeline. Now we have two other  branches we had just today called
           * +{{feature-abc}}+ {{+/navbar+ }}
           * {{{+}feature-abc{+}{+}/menu{+}}} .

          Notice the name has same prefix with branch +{{feature-abc}}+ .

           
          h4. The issue:
          {code:java}
          error: cannot lock ref 'refs/remotes/origin/feature-abc/menu': 'refs/remotes/origin/feature-abc' exists;
          cannot create 'refs/remotes/origin/feature-abc/navbar' From https://github.com/MyOrg/mywebapp

          ! [new branch] feature-abc/navbar -> origin/feature-abc/navbar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/navbar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/navbar'

          ! [new branch] feature-abc/menubar -> origin/feature-abc/menubar (unable to update local ref)
             error: cannot lock ref 'refs/remotes/origin/feature-abc/menubar': 'refs/remotes/origin/feature-abc' exists;
             cannot create 'refs/remotes/origin/feature-abc/menubar'{code}
           

          The solution I know is by running the following in the jenkins master server node.
          {code:java}
          git fetch --prune origin{code}
          h3. {color:#4c9aff}But I don't like manual work as this issue kept coming once in a while.
          {color}{color:#4c9aff}I wonder if there is a way to tell gitParameter to prune the stale reference. Thanks!{color}

            klimas7 Boguslaw Klimas
            danarbo Dan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: