赞
踩
Jenkins出现了陈旧的分支和远程git服务器有冲突, 如下:
- ERROR: Error fetching remote repo 'origin'
- hudson.plugins.git.GitException: Failed to fetch from git@XXX
- at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:894)
- at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1161)
- at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192)
- at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:124)
- at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
- at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
- at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
- at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
- at java.util.concurrent.FutureTask.run(FutureTask.java:266)
- at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
- at java.lang.Thread.run(Thread.java:748)
- Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- git@XXX +refs/heads/*:refs/remotes/origin/*" returned status code 1:
- stdout:
- stderr: error: cannot lock ref 'refs/remotes/origin/xxx': 'refs/remotes/origin/xxx' exists; cannot create 'refs/remotes/origin/xxx'
- From xxx
- ! [new branch] xxx -> origin/xxx (unable to update local ref)
- error: some local refs could not be updated; try running
- 'git remote prune xxx' to remove any old, conflicting branches
-
- at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2174)
- at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1866)
- at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:78)
- at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:547)
- at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:892)
- ... 11 more
在网上找了很多方法都不行, 去国外网站找了一圈也没有答案, 想了想, Jenkins的git流水线插件不应该做得那么搓, 绝对会把这个问题考虑进去了, 从生产流水线语法入手查查有没有更好的方法:
流水线语法的入口有2个地方:
1)
2)
进去之后呢, 如下:
看的时候感觉上面部门, 就是一些git的常用配置, 感觉都没有特别, 再往下一看:
没错, 就是它(PruneStaleBranch), 可以修建修剪陈旧的远程跟踪分支, 在这里补上, 重新点击构建, 成功了:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。