环境:
Jenkins和GitLab都加载到Nginx上。它们通过代理访问,每个端口都有不同的端口(即Jenkins可通过jenkins.mysite.com访问,GitLab可通过gitlab.mysite.com访问)。这是在/etc/nginx/conf.d/vhost
中配置的。我还将Manage Jenkins -> Manage Plugins -> Advanced -> HTTP proxy configuration
的HTTP代理配置设置为以下内容。
Server: xxx.xxx.xxx.xxx
Port: 8084 (GitLab)
虽然我设法在Jenkins服务器上与Gitlab成功连接,但我仍然无法连接到GitLab存储库。
我发现通过这种方式与GitLab的连接是成功的。
Jenkins -> Manage Jenkins -> System Configuration -> Gitlab -> entering the Gitlab host URL and Credentials and then click 'Test Connection' -> Success
之后我创建了一个新项目,以查看Jenkins是否成功使用Gitlab存储库。在完成所有装备后,我运行了构建,得到了以下结果。
Building in workspace /var/lib/jenkins/workspace/Skeleton
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url http://jenkins@gitlab.mysite.com:8084/Web-API-Skeleton/Foo-Api-Skeleton.git # timeout=10
Fetching upstream changes from http://jenkins@gitlab.mysite.com:8084/Web-API-Skeleton/Foo-Api-Skeleton.git
> /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials
Setting http proxy: xxx.xxx.xxx.xxx:8084
> /usr/bin/git fetch --tags --progress http://jenkins@gitlab.mysite.com:8084/Web-API-Skeleton/Foo-Api-Skeleton.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from http://jenkins@gitlab.mysite.com:8084/Web-API-Skeleton/Foodtechkorea-Api-Skeleton.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:812)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1079)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1110)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:560)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:485)
at hudson.model.Run.execute(Run.java:1735)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:405)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress http://jenkins@gitlab.mysite.com:8084/Web-API-Skeleton/Foo-Api-Skeleton.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: fatal: unable to access 'http://jenkins@gitlab.mysite.com:8084/Web-API-Skeleton/Foo-Api-Skeleton.git/': The requested URL returned error: 400
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1903)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1622)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:348)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:810)
... 11 more
ERROR: Error fetching remote repo 'origin'
An attempt to send an e-mail to empty list of recipients, ignored.
Finished: FAILURE