出了什么问题
我有一个ubuntu12.10服务器。
I将Jenkins和Nginx安装在同一台服务器上.
Nginx用于服务器文件的/var/虚拟文件具有www-data:www-data的权限设置。
用户jenkins正在运行Jenkins软件。

这是我用phing build.xml编写的目标
<target name="gitclone">
<echo msg="gitclone ${environment.branch} branch code to ${environment} environment" />
<exec command="ssh -A ${host-used} 'git clone -b ${repository-uri} ${environment.branch} ${environment.sitedir}${build.time}'"
outputProperty="result" escape="false"/>
<echo msg="${result}" />
<echo msg="update all the submodules after gitclone" />
<exec dir="${environment.sitedir}${build.time}" command="ssh -A ${host-used} 'git submodule update --init --recursive'" outputProperty="result" escape="false" />
<echo msg="${result}" />
</target>这是我来自jenkins的控制台输出:
[echo] gitclone master branch code to production environment
[echo] Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
[echo] update all the submodules after gitclone
Execution of target "gitclone" failed for the following reason: /var/lib/jenkins/jobs/abc-master/workspace/build.xml:116:48: '/var/virtual/abc.com/2013_01_11_07_45_35' is not a valid directory我试过的
我搜索了一下,然后我看到了这篇关于ssh代理转发的github文章。
这就是我试过的。
我以詹金斯的身份进入服务器。
然后我打字
ssh -T www-data@xxx.xx.xxx.xx我被提示输入www-data@xxx.x.xx.xx密码,然后我给出了密码。请注意,从现在开始,xxx.xx.xxx.xx引用同一服务器的ip地址。
我成功地以www-data登录,所以退出www-data@xxx.x.xx.xx。现在以jenkins用户的身份返回服务器。
现在我试着
echo "$SSH_AUTH_SOCK"我什么都没有。
我进入了/var/lib/jenkins/..ssh/config,输入了以下内容:
Host xxx.xx.xxx.xx
ForwardAgent yes
IdentityFile /var/lib/jenkins/.ssh/id_rsa
StrictHostkeyChecking no再次构建Jenkins作业。失败。
然后,我想也许我需要在www-data ~/..ssh/ authorized_keys _key文件中设置jenkins@xxx.xx.xxx.xx,这样每当我们从jenkins@xxx.xx.xxx.xx转到www-data@xx.x.xx.xx时,我就不会收到密码提示。
所以作为jenkins,我输入了
cat ~/.ssh/id_rsa.pub | ssh www-data@xxx.xx.xxx.xx 'cat >> .ssh/authorized_keys'然后我打字
ssh -T www-data@xxx.xx.xxx.xx我被提示输入www-data@xxx.x.xx.xx密码,然后我给出了密码。
我成功地以www-data 登录,这一次没有被提示输入密码,所以我退出www-data@xxx.x.xx.xx。现在以jenkins用户的身份返回服务器。
再次构建Jenkins作业。失败。
作为jenkins,我输入了
echo "$SSH_AUTH_SOCK"什么也没看到。
试过
ssh-add -L得到
Could not open a connection to your authentication agent.编辑/etc/ssh/sshd_config并添加
AllowAgentForwarding yes检查了/etc/ssh/ssh_config。没有ForwardAgent no设置。
再次构建Jenkins作业。失败。
发布于 2013-01-12 02:50:46
首先,我注意到您的git克隆命令可能写错了。
检查:
<exec command="ssh -A ${host-used} 'git clone -b ${environment.branch} ${repository-uri} ${environment.sitedir}${build.time}'"我交换了${environment.branch}和${repository-uri}的位置。
参考资料:git-克隆(1)手册页
发布于 2013-01-13 18:55:10
我建议你用ant-jsch
我已经在詹金斯手下用过蚂蚁。
ant-jsch能够控制ssh识别等等。
https://stackoverflow.com/questions/14274437
复制相似问题