在Jenkins中执行"git fetch --tags --progress"超时,但在命令行中可以正常工作。

9

我已经配置了Jenkins来轮询一个Git代码库,使用的是https而不是ssh。下面是已配置的URL,我使用用户名和密码。

https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git

当我运行构建时,它会停顿10分钟并超时。当我复制超时的那一行,并粘贴到与Jenkins运行的同一台机器上(一个macOS服务器)的命令行中,它可以正常工作:

git fetch --tags --progress https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git +refs/heads/*:refs/remotes/origin/*

为什么它会卡了10分钟?我试图使用错误的凭据,这会在一秒钟内失败。它不是一个巨大的代码库。
日志信息:
Started by user Jenkins Admin
Building in workspace /Users/Shared/Jenkins/Home/workspace/Build and test new commits on develop
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git # timeout=10
Fetching upstream changes from https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:803)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1063)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1094)
    at hudson.scm.SCM.checkout(SCM.java:495)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1278)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
    at hudson.model.Run.execute(Run.java:1728)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:404)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git +refs/heads/*:refs/remotes/origin/*" returned status code 143:stdout: 
stderr: 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1745)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1489)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:801)
    ... 11 more
ERROR: null
Finished: FAILURE

1
Git的轮询日志显示了有用的内容吗? - Haldean Brown
1
你能否将 Jenkins 的“构建控制台输出”附加到你的原始帖子中? - Sajib Khan
1
当您在控制台中运行命令时,是否在与Jenkins作业相同的存储库和使用相同的用户下运行它? - Haldean Brown
2
我将Jenkins添加为macOS的用户,并登录为Jenkins。再次运行同样的任务,它成功了。如果Ivan或@HaldeanBrown中的任何一个想要收集荣耀,请回答,我已经厌倦了在这里回答自己的问题 ;) 在http://www.cimgf.com/2015/05/26/setting-up-jenkins-ci-on-a-mac-2/上找到了解决方案,“设置Jenkins用户”。 - Lucas van Dongen
2
@Ivan更接近正确答案,他可以拥有它 :) - Haldean Brown
显示剩余3条评论
1个回答

3
请检查您的操作系统上是否存在用户jenkins,并且它具有正确的权限。
如何在Mac OS X上设置jenkins用户: 编辑 请尝试以下操作(我没有测试过):
  • 将Jenkins用户设置为管理员:sudo dseditgroup -o edit -a jenkins -t user admin

  • 将Jenkins用户添加到开发人员组:sudo dscl . append /Groups/_developer GroupMembership jenkins

  • 使Jenkins用户在计算机重新启动时自动登录


如果你的Windows上的Jenkins从机正在以“本地服务”用户身份运行为服务,则可以将其更改为另一个“真实”的用户。这样,您就可以使用此用户登录Windows并检查任何命令(例如“git clone”)和任何权限。 - Ivan
答案已经没有帮助了。链接失效。 - Joel Anderson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接