Initial Commit
Some checks failed
LXC-ImageBuilder/Ubuntu/pipeline/head There was a failure building this commit
Some checks failed
LXC-ImageBuilder/Ubuntu/pipeline/head There was a failure building this commit
This commit is contained in:
89
Jenkinsfile
vendored
Normal file
89
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
pipeline {
|
||||||
|
agent { label 'LXCBuilder' }
|
||||||
|
parameters {
|
||||||
|
booleanParam defaultValue: true, description: 'Builds Default images', name: 'BuildDefault'
|
||||||
|
booleanParam defaultValue: false, description: 'Builds Extra images', name: 'BuildExtra'
|
||||||
|
}
|
||||||
|
options {
|
||||||
|
skipDefaultCheckout()
|
||||||
|
buildDiscarder(logRotator(numToKeepStr: '2', artifactNumToKeepStr: '1'))
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('Prepare') {
|
||||||
|
steps {
|
||||||
|
// Cleanup before starting
|
||||||
|
cleanWs()
|
||||||
|
// Checkout the repository
|
||||||
|
checkout scm
|
||||||
|
// Get distrobuilder
|
||||||
|
copyArtifacts filter: 'bin/distrobuilder', fingerprintArtifacts: true, flatten: true, projectName: '/Public/DistroBuilder/BuildConfig=BrampCustom', selector: lastSuccessful()
|
||||||
|
// Setup Env
|
||||||
|
sh '''mkdir $WORKSPACE/REL'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("Image Configs") {
|
||||||
|
matrix {
|
||||||
|
axes {
|
||||||
|
axis {
|
||||||
|
name 'ImgRelease'
|
||||||
|
values 'bionic', 'focal'
|
||||||
|
}
|
||||||
|
axis {
|
||||||
|
name 'ImgVariant'
|
||||||
|
values 'Default-minmal', 'Default-default'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Exclude unwanted conbinatinations
|
||||||
|
excludes {
|
||||||
|
exclude {
|
||||||
|
axis {
|
||||||
|
name 'ImgRelease'
|
||||||
|
values 'bionic'
|
||||||
|
}
|
||||||
|
axis {
|
||||||
|
name 'ImgVariant'
|
||||||
|
//use notValues to invert
|
||||||
|
notValues 'Default-default'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('Build image') {
|
||||||
|
when {
|
||||||
|
//ImgTypeTest
|
||||||
|
anyOf {
|
||||||
|
allOf {
|
||||||
|
expression { return (env.ImgVariant).startsWith('Default-') }
|
||||||
|
environment name: 'BuildDefault', value: 'true'
|
||||||
|
}
|
||||||
|
allOf {
|
||||||
|
expression { return (env.ImgVariant).startsWith('Extra-') }
|
||||||
|
environment name: 'BuildExtra', value: 'true'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
// Build script
|
||||||
|
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
|
||||||
|
sh '''echo "$(date) Do Build for $ImgRelease - $ImgVariant"
|
||||||
|
ImgVariantName=${ImgVariant#Default-} && ImgVariantName=${ImgVariantName#Extra-}
|
||||||
|
sudo $WORKSPACE/distrobuilder build-lxc Ubuntu.yaml $WORKSPACE/REL/$ImgRelease-$ImgVariant/ -o image.release=$ImgRelease -o image.variant=$ImgVariantName
|
||||||
|
sudo chown jenkins:jenkins -R $WORKSPACE/REL
|
||||||
|
mv $WORKSPACE/REL/$ImgRelease-$ImgVariant/rootfs.tar.xz Ubuntu-$ImgRelease-$ImgVariant.tar.xz
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Finish') {
|
||||||
|
steps {
|
||||||
|
// Save generated files
|
||||||
|
archiveArtifacts artifacts: '*.tar.xz', followSymlinks: false
|
||||||
|
// Cleaning WorkSpace
|
||||||
|
//cleanWs()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
138
Ubuntu.yaml
Normal file
138
Ubuntu.yaml
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
image:
|
||||||
|
distribution: ubuntu
|
||||||
|
|
||||||
|
source:
|
||||||
|
downloader: debootstrap
|
||||||
|
same_as: gutsy
|
||||||
|
url: http://192.168.2.83/archive.ubuntu.com/ubuntu
|
||||||
|
keyserver: keyserver.ubuntu.com
|
||||||
|
keys:
|
||||||
|
- 0x790BC7277767219C42C86F933B4FE6ACC0B21F32
|
||||||
|
- 0xf6ecb3762474eda9d21b7022871920d1991bc93c
|
||||||
|
|
||||||
|
targets:
|
||||||
|
lxc:
|
||||||
|
create-message: |-
|
||||||
|
You just created an {{ image.description }} container.
|
||||||
|
config:
|
||||||
|
- type: all
|
||||||
|
before: 5
|
||||||
|
content: |-
|
||||||
|
lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.common.conf
|
||||||
|
|
||||||
|
- type: user
|
||||||
|
before: 5
|
||||||
|
content: |-
|
||||||
|
lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.userns.conf
|
||||||
|
|
||||||
|
- type: all
|
||||||
|
after: 4
|
||||||
|
content: |-
|
||||||
|
lxc.include = LXC_TEMPLATE_CONFIG/common.conf
|
||||||
|
|
||||||
|
# For Ubuntu 14.04
|
||||||
|
lxc.mount.entry = /sys/kernel/debug sys/kernel/debug none bind,optional 0 0
|
||||||
|
lxc.mount.entry = /sys/kernel/security sys/kernel/security none bind,optional 0 0
|
||||||
|
lxc.mount.entry = /sys/fs/pstore sys/fs/pstore none bind,optional 0 0
|
||||||
|
lxc.mount.entry = mqueue dev/mqueue mqueue rw,relatime,create=dir,optional 0 0
|
||||||
|
|
||||||
|
- type: user
|
||||||
|
after: 4
|
||||||
|
content: |-
|
||||||
|
lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
|
||||||
|
|
||||||
|
# For Ubuntu 14.04
|
||||||
|
lxc.mount.entry = /sys/firmware/efi/efivars sys/firmware/efi/efivars none bind,optional 0 0
|
||||||
|
lxc.mount.entry = /proc/sys/fs/binfmt_misc proc/sys/fs/binfmt_misc none bind,optional 0 0
|
||||||
|
|
||||||
|
- type: all
|
||||||
|
content: |-
|
||||||
|
lxc.arch = {{ image.architecture_personality }}
|
||||||
|
|
||||||
|
files:
|
||||||
|
- path: /etc/hostname
|
||||||
|
generator: hostname
|
||||||
|
|
||||||
|
- path: /etc/hosts
|
||||||
|
generator: hosts
|
||||||
|
|
||||||
|
- path: /etc/resolvconf/resolv.conf.d/original
|
||||||
|
generator: remove
|
||||||
|
|
||||||
|
- path: /etc/resolvconf/resolv.conf.d/tail
|
||||||
|
generator: remove
|
||||||
|
|
||||||
|
- path: /etc/machine-id
|
||||||
|
generator: dump
|
||||||
|
|
||||||
|
- path: /var/lib/dbus/machine-id
|
||||||
|
generator: remove
|
||||||
|
|
||||||
|
- path: /etc/netplan/10-lxc.yaml
|
||||||
|
generator: dump
|
||||||
|
content: |-
|
||||||
|
network:
|
||||||
|
version: 2
|
||||||
|
ethernets:
|
||||||
|
eth0:
|
||||||
|
dhcp4: true
|
||||||
|
dhcp-identifier: mac
|
||||||
|
types:
|
||||||
|
- container
|
||||||
|
|
||||||
|
packages:
|
||||||
|
manager: apt
|
||||||
|
update: true
|
||||||
|
cleanup: true
|
||||||
|
sets:
|
||||||
|
- packages:
|
||||||
|
- language-pack-en
|
||||||
|
- openssh-client
|
||||||
|
action: install
|
||||||
|
- packages:
|
||||||
|
- nano
|
||||||
|
action: install
|
||||||
|
variants:
|
||||||
|
- default
|
||||||
|
|
||||||
|
repositories:
|
||||||
|
- name: sources.list
|
||||||
|
url: |-
|
||||||
|
deb http://archive.ubuntu.com/ubuntu {{ image.release }} main restricted universe multiverse
|
||||||
|
deb http://archive.ubuntu.com/ubuntu {{ image.release }}-updates main restricted universe multiverse
|
||||||
|
deb http://security.ubuntu.com/ubuntu {{ image.release }}-security main restricted universe multiverse
|
||||||
|
|
||||||
|
actions:
|
||||||
|
- trigger: post-unpack
|
||||||
|
action: |-
|
||||||
|
#!/bin/sh
|
||||||
|
echo 'Acquire::http::Proxy "http://192.168.2.83:80";' > /etc/apt/apt.conf.d/01prox
|
||||||
|
echo '#Acquire::http::Proxy "http://192.168.200.60:80";' >> /etc/apt/apt.conf.d/01prox
|
||||||
|
|
||||||
|
- trigger: post-packages
|
||||||
|
action: |-
|
||||||
|
#!/bin/sh
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
# Enable systemd-networkd
|
||||||
|
systemctl enable systemd-networkd
|
||||||
|
|
||||||
|
- trigger: post-packages
|
||||||
|
action: |-
|
||||||
|
#!/bin/sh
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
# Make sure the locale is built and functional
|
||||||
|
locale-gen en_US.UTF-8
|
||||||
|
update-locale LANG=en_US.UTF-8
|
||||||
|
|
||||||
|
# Cleanup underlying /run
|
||||||
|
mount -o bind / /mnt
|
||||||
|
rm -rf /mnt/run/*
|
||||||
|
umount /mnt
|
||||||
|
|
||||||
|
# Cleanup temporary shadow paths
|
||||||
|
rm /etc/*-
|
||||||
|
|
||||||
|
mappings:
|
||||||
|
architecture_map: debian
|
||||||
Reference in New Issue
Block a user