gpt4 book ai didi

git - 为什么 Jenkins 在从 git 获取时失败,而命令行却没有?

转载 作者:IT王子 更新时间:2023-10-29 01:13:38 26 4
gpt4 key购买 nike

我所有的 Jenkins 构建都在 git fetch 行失败。

它在 git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git 处失败了

Started by user anonymous
Building in workspace /Users/ethen/.jenkins/workspace/Build NikNik
> git rev-parse --is-inside-work-tree
Fetching changes from the remote Git repository
> git config remote.origin.url git@bitbucket.org:ethenwilson/whentoact.git
Fetching upstream changes from git@bitbucket.org:ethenwilson/whentoact.git
> git --version
using GIT_SSH to set credentials NikNik BitBucket SSH Key
> git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*
FATAL: Failed to fetch from git@bitbucket.org:ethenwilson/whentoact.git
hudson.plugins.git.GitException: Failed to fetch from git@bitbucket.org:ethenwilson/whentoact.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:622)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:854)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:879)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1252)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:624)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:530)
at hudson.model.Run.execute(Run.java:1732)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:234)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Counting objects: 2682, done.[K
remote: Compressing objects: 0% (1/1399) [K
remote: Compressing objects: 1% (14/1399) [K
...
remote: Compressing objects: 99% (1398/1399) [K
remote: Compressing objects: 100% (1399/1399) [K
remote: Compressing objects: 100% (1399/1399), done.[K
Receiving objects: 0% (1/2682)
Receiving objects: 1% (27/2682)
...
Receiving objects: 78% (2092/2682), 4.07 MiB | 1.59 MiB/s
Corrupted MAC on input.
Disconnecting: Packet corrupt
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1325)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1186)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:257)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:620)
... 10 more

当我从命令行运行 git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git 时,它工作正常,这意味着我的 SSH key 必须工作。

我正在使用 Jenkins 通过 SSH 验证连接到 BitBucket。 Jenkins 从它所在的文件(默认文件)中获取 key ,因此我知道 Jenkins 使用的 key 与我从命令行运行时使用的 key 相同。

我正在为 Jenkins 使用最新版本的 BitBucket 和 Git 插件。我在 Mac 上安装的 Git 版本是 1.8.5.2 (Apple Git-48)

我的 jenkins 启动命令是 nohup java -jar ~/jenkins.war --httpPort=8081 --ajp13Port=8010 >/tmp/jenkins.log 2>&1 &

出了什么问题?

编辑:我错了,我不小心点击了一个选项,让 SSH key 位于错误的位置。现在,使用@borrrden 的建议,它仍然给出相同的错误。 **编辑: 正如@borrrden 所建议的,我将启动命令更改为 nohup java -Dorg.jenkinsci.plugins.gitclient.Git.useCLI=true -jar ~/Downloads/jenkins.war --httpPort=8081 --ajp13Port=8010 >/tmp/jenkins.log 2>&1 &,现在我遇到了不同的崩溃:

Started by user anonymous
Building in workspace /Users/ethen/.jenkins/workspace/Build NikNik
> git rev-parse --is-inside-work-tree
Fetching changes from the remote Git repository
> git config remote.origin.url git@bitbucket.org:ethenwilson/whentoact.git
Fetching upstream changes from git@bitbucket.org:ethenwilson/whentoact.git
> git --version
using GIT_SSH to set credentials NikNik BitBucket SSH Key
> git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*
FATAL: Failed to fetch from git@bitbucket.org:ethenwilson/whentoact.git
hudson.plugins.git.GitException: Failed to fetch from git@bitbucket.org:ethenwilson/whentoact.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:622)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:854)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:879)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1252)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:624)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:530)
at hudson.model.Run.execute(Run.java:1732)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:234)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1406)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1194)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:265)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:620)
... 10 more

最佳答案

enter image description here1) 进入作业配置

2) 转到“源代码管理”部分

3) 附加行为> 添加

4) 选择“清除存储库并强制克隆”

这将只删除并重新克隆适合您的工作的工作区。如果您想在删除前确认,那么我建议通过批处理/bash 命令构建步骤回显 $WORKSPACE 变量。

此外,这会使构建速度变慢,因此我建议在一次构建后将其删除。

关于git - 为什么 Jenkins 在从 git 获取时失败,而命令行却没有?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24813816/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com