在Jenkins中使用git fetch --tags --progress超时,在命令行上运行正常

Dep*_*o B 8 git macos jenkins

我已经将Jenkins配置为轮询Git存储库,我使用的是https而不是ssh.配置了以下URL,我使用用户名和密码.

https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git
Run Code Online (Sandbox Code Playgroud)

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

git fetch --tags --progress https://myusername@stash.ourdomain.com:8443/scm/ourrepo/ourrepo-ios.git +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)

为什么它会停留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
Run Code Online (Sandbox Code Playgroud)

Iva*_*van 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用户在电脑重启时自动登录