当前位置:   article > 正文

Jenkins的pipeline如何“修剪陈旧的远程跟踪分支”?_jenkins stderr: error: cannot lock ref

jenkins stderr: error: cannot lock ref

Jenkins出现了陈旧的分支和远程git服务器有冲突, 如下:

  1. ERROR: Error fetching remote repo 'origin'
  2. hudson.plugins.git.GitException: Failed to fetch from git@XXX
  3. at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:894)
  4. at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1161)
  5. at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192)
  6. at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:124)
  7. at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
  8. at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
  9. at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
  10. at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
  11. at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  12. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  13. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  14. at java.lang.Thread.run(Thread.java:748)
  15. Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- git@XXX +refs/heads/*:refs/remotes/origin/*" returned status code 1:
  16. stdout:
  17. stderr: error: cannot lock ref 'refs/remotes/origin/xxx': 'refs/remotes/origin/xxx' exists; cannot create 'refs/remotes/origin/xxx'
  18. From xxx
  19. ! [new branch] xxx -> origin/xxx (unable to update local ref)
  20. error: some local refs could not be updated; try running
  21. 'git remote prune xxx' to remove any old, conflicting branches
  22. at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2174)
  23. at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1866)
  24. at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:78)
  25. at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:547)
  26. at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:892)
  27. ... 11 more

在网上找了很多方法都不行, 去国外网站找了一圈也没有答案, 想了想, Jenkins的git流水线插件不应该做得那么搓, 绝对会把这个问题考虑进去了, 从生产流水线语法入手查查有没有更好的方法:

流水线语法的入口有2个地方:

1)

2) 

进去之后呢, 如下:

看的时候感觉上面部门, 就是一些git的常用配置, 感觉都没有特别, 再往下一看:

没错, 就是它(PruneStaleBranch), 可以修建修剪陈旧的远程跟踪分支, 在这里补上, 重新点击构建, 成功了:

 

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号