jenkinsci / jenkinsci/git-parameter-plugin
[JENKINS-71512] GitParameter not cleaning up stale ref branch
- Dominant language
- Java
- Stars
- 131
- Forks
- 134
- Avg merge
- 21h 5m
- Merged PRs (30d)
- 1
Description
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!
---
Originally reported by danarbo, imported from: GitParameter not cleaning up stale ref branch
Raw content of original issue
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!
- environment:
Docker Image: jenkins/jenkins:2.401.1-jdk11
Contributor guide
Assessment
This issue has not been assessed yet.