2015-02-05 59 views
1

我有一个项目,我想与詹金斯一起建立。 该项目是在一个私人的GitHub回购托管,我已经把SSH公钥放在我的用户“部署”的GitHub中。如何让詹金斯通过作曲家检查私人供应商回购

由于构建配置中Jenkins git插件部分的部署证书,项目得到了很好的检查。 但其托管在GitHub上同私营机构供应商LIB通过构建步骤的命令加载:

php composer.phar install -o --prefer-dist --no-dev 

我安装詹金斯git的插件,以便通过SSH私钥签从GitHub主要回购。 但是当作曲家试图检出子项目我得到

Failed to clone the [email protected]:Organisation/Repo.git repository, try running in interactive mode so that you can enter your GitHub credentials 

我试图让作曲家命令跑了作为没有成功不同的用户有喜欢的东西:

su - deploy -c 'php composer.phar install -o --prefer-dist --no-dev' 

看起来奇怪呢。我想弄清楚让作曲家完成他的工作的正确方法。想过?

+0

有关信息,我发现某种解决办法的。在JENKINS-CI中以另一个用户身份执行shell脚本https://fixitagain.wordpress.com/2011/07/29/executing-a-shell-script-as-another-user-in-jenkins-ci/ – Jerem 2015-02-05 18:42:08

回答

2

Jenkins实际上是以“jenkins”用户的身份运行shell命令。 这意味着“jenkins”需要访问GitHub。 然后所有[email protected]:Organisation/Repo.git将无需额外的凭据工作。

这里解释如何通过SSH

# Login as the jenkins user and specify shell explicity, 
# since the default shell is /bin/false for most 
# jenkins installations. 
sudo su jenkins -s /bin/bash 

ssh-keygen -t rsa -C "[email protected]" 
# Copy ~/.ssh/id_rsa.pub into your Github 

# Allow adding the SSH host key to your known_hosts 
ssh -T [email protected] 

# Exit from su 
exit 

从启发授予GitHub的詹金斯访问:Managing SSH keys within Jenkins for Git