git - 如何通过 Jenkins 防止 git checkout 错误
问题描述
我的 Jenkins 构建偶尔会进入无法构建的状态。我已经包含了构建输出,因为我不确定是什么失败了。日志很长,不清楚错误到底是什么。为了隐私和简洁起见,我删除了一些日志,但试图留下相关的细节。
显然,它无法签出 git repo。由于输出路径是 ...script 我假设它正在尝试签出共享库。
我认为最根本的错误是:
无法写入文件 .git/objects/pack/pack-164b9e3f86c3751d8ec0f3a14d1e3df6c85e29b4.pack:权限被拒绝
我想不出什么会导致文件被锁定。
或者这可能是根本错误:
stderr: Logon failed, use ctrl+c to cancel basic credential prompt.
要修复,我删除工作区并重新构建。这个问题每周发生多次——这是一个严重的问题,但只要我能解决它,我们仍然可以解决这个问题。
Jenkins 中心节点是 Windows 10,运行最新版本的 Jenkins。
Checking out git .../NextGen into E:\Jenkins\workspace\Vision-adhoc-script to read vision-jenkinsfile.groovy
The recommended git tool is: NONE
using credential ...
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url .../NextGen # timeout=10
Cleaning workspace
> git rev-parse --verify HEAD # timeout=10
Resetting working tree
> git reset --hard # timeout=10
> git clean -fdx # timeout=10
Using shallow fetch with depth 1
Fetching upstream changes from .../NextGen
> git --version # timeout=10
> git --version # 'git version 2.25.1.windows.1'
using GIT_ASKPASS to set credentials
> git fetch --tags --force --progress --depth=1 -- .../NextGen +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from .../NextGen
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1001)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1242)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1302)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:155)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:69)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --depth=1 -- .../NextGen +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: Logon failed, use ctrl+c to cancel basic credential prompt.
remote: Microsoft (R) Visual Studio (R) Team Foundation Server
remote:
remote: Found 1561 objects to send. (599 ms)
Receiving objects: 100% (1561/1561), 248.74 KiB | 13.09 MiB/s, done.
Resolving deltas: 100% (19/19), done.
error: unable to write file .git/objects/pack/pack-164b9e3f86c3751d8ec0f3a14d1e3df6c85e29b4.pack: Permission denied
fatal: cannot store pack file
fatal: index-pack failed
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999)
... 8 more
ERROR: Error fetching remote repo 'origin'
Retrying after 10 seconds
--log repeats with same output on several retries--
ERROR: Maximum checkout retry attempts reached, aborting
Finished: FAILURE
解决方案
推荐阅读
- linux - 如何获取 sftp 服务器的当前日期和时区(日期命令不起作用)
- assembly - x86_64 cmp 指令操作码和操作数的组合无效
- java - 如果在数组搜索中找不到打印用户输入的语句
- java - 有没有办法获取 MessageFormat 对象模式的最大索引参数?
- c# - 条纹:未找到“SessionSubscriptionDataOptions”缺少程序集参考 Visual Studio 2019
- string - 在 shell 变量值中转义前斜杠
- azure - Azure 认知搜索不安全/保留字符
- ibm-cloud - 如何在 Cloudant 帐户中为 Bluemix 定价计算 IO 操作?(吞吐量 - 查找、读取、写入、查询)
- swift - DocumentID 每次在 firebase 中都会更新
- mysql - MySQL 导入 - XY 行出现错误 1054 (42S22):“字段列表”中的未知列“X”