我正在尝试使用GIT插件Jenkins从GIT中拉出代码,该作业正在从属机器上运行。
MASTER
系统有http_proxy=mycom.domain.com:80
并且在SLAVE
系统中没有定义http_proxy
。
每当我在SLAVE
机器上本地进行git克隆时,它都能完美地工作,但是在Jenkins上我并没有成功。
它抛出以下错误:
Building remotely on SLAVE in workspace /data/test
> /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 https://github.domain.com/Project-Digital/Project-eCommerce.git # timeout=10
Fetching upstream changes from https://github.domain.com/Project-Digital/Project-eCommerce.git
> /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials
Setting http proxy: mycom.domain.com:80
> /usr/bin/git fetch --tags --progress https://github.domain.com/Project-Digital/Project-eCommerce.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.domain.com/Project-Digital/Project-eCommerce.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 "/usr/bin/git fetch --tags --progress https://github.domain.com/Project-Digital/Project-eCommerce.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: error: Failed connect to github.build.ge.com:80; Operation now in progress while accessing https://github.domain.com/Project-Digital/Project-eCommerce.git/info/refs
是否因为MASTER
系统试图设置SLAVE
系统中不存在的http代理?
若有,如何预防?
或者,我还遗漏了什么吗?
发布于 2017-01-20 17:15:01
原来这是个代理问题。
当使用Jenkins从GIT中提取代码时,它将http_proxy
设置为mycom.domain.com:80
(MASTER
机器代理),而这个代理在SLAVE
机器中不是必需的。
所以,我刚刚在Jenkins的No Proxy Host部分(Manage Jenkins -> Manage Plugins -> Advanced -> HTTP Proxy Configuration -> Added GIT URL in No Proxy Host field)
中添加了GIT URL,现在它工作得很好。
发布于 2017-01-19 21:04:11
在拉取工程之前,请尝试在全局配置中设置HTTP代理:
$> git config --global http.proxy http://mycom.example.com:80
如果您需要为代理提供用户名和密码,您可以使用:
$> git config --global http.proxy http://example.com\\<yourUsername>:<yourPassword>@<yourProxyServer>:80
发布于 2017-01-19 21:38:27
今天我也用git仓库建立了jenkins,对我很有用,希望这能有所帮助。
要将git连接到jenkins,请执行以下步骤:
步骤1。成功安装插件后,创建一个新作业,如下所示:
1.创建作业名称
2.选中了Build a maven software project的单选按钮
3.点击OK
步骤2。现在选中Git的单选按钮,输入git存储库的uri。
步骤3。如果您将看到如下错误
无法连接到存储库:命令"git ls-remote -h git@example.git HEAD“返回状态代码128: stdout: stderr: fatal:'git@example.git‘似乎不是git存储库fatal:远程端意外挂起
你需要做更多的配置:
1.转到终端
2.运行以下命令:sudo visudo
3.添加%jenkins ALL=NOPASSWD:此文件中的所有sudo previlage为defined.and关闭该文件。
4.通过以下命令以jenkins用户身份登录:sudo su jenkins
5.在jenkins主目录中创建一个.ssh目录。
6.像这样创建公钥和私钥对。
生成SSH密钥:
SSH1:密钥的检查
首先,我们需要检查您的计算机上是否存在现有的ssh密钥。打开终端并运行:
cd ~/.ssh检查用户目录中是否存在名为".ssh“的目录
如果显示“没有这样的文件或目录”,请转到步骤2。否则,您已经有了一个密钥对,您可以跳到步骤3。
SSH2:生成新的密钥
要生成新的SSH密钥,请输入以下代码。我们需要默认设置,因此当要求输入保存密钥的文件时,只需按enter键即可。
ssh-keygen -t rsa -C "your_email@example.com"
创建新的ssh密钥,使用提供的电子邮件作为标签生成公共/私有rsa密钥对。输入保存密钥的文件(/home/ you /.ssh/id_rsa):现在您需要输入密码或file.press Enter,而不需要写入任何内容。
这应该会给你类似这样的结果:
您的标识已保存在/home/you/.ssh/id_rsa.中
您的公钥已保存在/home/you/.ssh/id_rsa.pub.中,密钥指纹为:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
SSH3:将您的密钥添加到GitHub
转到您的帐户设置
4 :源管理标签下的,
Build Triggers- Build whenever a SNAPSHOT dependency is built
Root POM- /var/lib/jenkins/jobs/ProjectName/workspace/ProjectName/pom.xml
在execute Shell标签下,您可以将脚本放入中执行。
最后单击build Now创建构建,打开控制台检查状态。
https://stackoverflow.com/questions/41741762
复制相似问题