-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major
-
Component/s: git-parameter-plugin
-
Environment:Docker Image: jenkins/jenkins:2.401.1-jdk11
-
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