当前位置:主页 > 查看内容

Jenkins的pipeline如何“修剪陈旧的远程跟踪分支”?

发布时间:2021-09-08 00:00| 位朋友查看

简介:Jenkins出现了陈旧的分支和远程git服务器有冲突, 如下: ERROR: Error fetching remote repo originhudson.plugins.git.GitException: Failed to fetch from gitXXXat hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:894)at hudson.plugins.git.GitSCM.ret……

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), 可以修建修剪陈旧的远程跟踪分支, 在这里补上, 重新点击构建, 成功了:

?

;原文链接:https://blog.csdn.net/CrazyRango/article/details/115918143
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!
上一篇:初识数据库的笔记 下一篇:没有了

推荐图文

  • 周排行
  • 月排行
  • 总排行

随机推荐