2015-08-08 42 views
3

我想要自动构建所有在chroot:如何为jenkins构建chroot?

sudo chroot mychroot 
apt-get install git build-essential make -y 
git clone myrepo 
cd myrepo/src 
make 

从这个线程,似乎我在管理詹金斯配置 - >配置系统应该是:

Name: trusty 
Tool: pbuilder 
Advanced configuration: checked 
Additional arguments: --distribution trusty --debootstrapopts --variant=buildd 

Shell command: 
Repositories: 
Name: universe 
Repository URL: deb http://us.archive.ubuntu.com/ubuntu/ trusty universe 
Keyfile URL: http://archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg 

我还添加了詹金斯成在issue中讨论的/etc/sudoers文件。

任何人都可以分享他们的配置吗?该wiki是伟大的,但我觉得有点欠缺:

什么是described here正是我想要的:

Creates a new debootstrap-based chroot. 
Installs build-essential, mercurial, etc. 
Fetches the shource. 
Runs make. 
Copies the files produced in ./binary-out/ to a safe location. 
Cleans up. 

回答

2

它是否适合提前准备一个chroot(比如所有作业使用相同的配置) ,那么你要可以很容易地在一个SSH从使用以下配置,以在从属的/ etc/SSH/sshd_config中达到什么:

Match User jenkins 
     ChrootDirectory /var/chroot/ 
     X11Forwarding no 
     AllowTcpForwarding no 

当詹金斯登录到从通过SSH进行构建,他会自动抛出在不需要将Jenkins添加到sudoers的情况下创建chroot,创建​​chroot并在构建魔法发生之前安装依赖关系。

在Jenkins总是与计算机上的chroot相同的情况下,这更简单一些,更不用说容易出错的路径了。

+0

好主意。然而,我的构建chroot并不稳定,而且随着它的发展每次都希望从头开始(并且我想确保我没有携带未知的工件,我想我可以有一个单独的工作来初始化chroot,然后当那一个完成时,使用其他工作直接跳入它。 – tarabyte