简体   繁体   English

如何为jenkins构建设置chroot?

[英]How to set up chroot for jenkins build?

I want to automate builds all in a chroot: 我想在chroot中自动化构建:

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

From this thread it seems my configuration in Manage Jenkins -> Configure System should be: 从这个线程看来,我在Manage Jenkins - > Configure System中的配置应该是:

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

I've also added jenkins into the /etc/sudoers file as discussed in this issue . 我还将jenkins添加到/etc/sudoers文件中,如本期所述

Can anyone share their configuration? 谁能分享他们的配置? The wiki is great but I feel a bit lacking: 维基很棒,但我觉得有点缺乏:

What is described here is exactly what I want: 这里描述的正是我想要的:

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.

If it is suitable to prepare a chroot in advance (say all jobs use the same configuration), then what you want can easily be achieved on an SSH slave by using the following configuration to /etc/ssh/sshd_config on the slave: 如果适合提前准备chroot(比如说所有作业都使用相同的配置),那么通过对slave上的/ etc / ssh / sshd_config使用以下配置,可以在SSH从站上轻松实现所需的功能:

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

When Jenkins log in to the slave over SSH to perform the build, he will automatically be thrown in to the chroot without the need to add Jenkins to sudoers, create a chroot, and install dependencies before the build magic can happen. 当Jenkins通过SSH登录到奴隶以执行构建时,他将自动被扔进chroot而无需在构建魔法发生之前将Jenkins添加到sudoers,创建chroot并安装依赖项。

In cases where Jenkins will always be in the same chroot on a machine, this is a much simpler, not to mention less error-prone, route to take. 如果Jenkins总是在机器上的同一个chroot中,这是一个更简单,更不用说容易出错的路线了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM