From 198d576802de90ff5c30c266312de24a0e7ff30b Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Sun, 21 Feb 2021 15:59:56 +0000 Subject: [PATCH] initial Commit --- Jenkinsfile | 90 ++++++++++++++++++++++ OpenSuse-Tumbleweed.yaml | 156 +++++++++++++++++++++++++++++++++++++++ opnsuse-Leap.yaml | 137 ++++++++++++++++++++++++++++++++++ 3 files changed, 383 insertions(+) create mode 100644 Jenkinsfile create mode 100644 OpenSuse-Tumbleweed.yaml create mode 100644 opnsuse-Leap.yaml diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..6a8d322 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,90 @@ +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 '15.2', 'tumbleweed' + } + axis { + name 'ImgVariant' + values 'Default-minmal', 'Default-default' + } + } + //Exclude unwanted conbinatinations + // excludes { + // exclude { + // axis { + // name 'ImgRelease' + // values 'edge' + // } + // axis { + // name 'ImgVariant' + // //use notValues to invert + // values 'Extra-extended' + // } + // } + // } + 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" + if [ $ImgRelease = "tumbleweed" ] ; then YamlVer=Tumbleweed ; else YamlVer=Leap ; fi + ImgVariantName=${ImgVariant#Default-} && ImgVariantName=${ImgVariantName#Extra-} + sudo $WORKSPACE/distrobuilder build-lxc OpenSuse-"$YamlVer".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 OpenSuse-$ImgRelease-$ImgVariant.tar.xz + ''' + } + } + } + } + } + } + stage('Finish') { + steps { + // Save generated files + archiveArtifacts artifacts: '*.tar.xz', followSymlinks: false + // Cleaning WorkSpace + //cleanWs() + } + } + } +} \ No newline at end of file diff --git a/OpenSuse-Tumbleweed.yaml b/OpenSuse-Tumbleweed.yaml new file mode 100644 index 0000000..e8850d7 --- /dev/null +++ b/OpenSuse-Tumbleweed.yaml @@ -0,0 +1,156 @@ +image: + distribution: openSUSE + release: tumbleweed + variant: default + +source: + downloader: opensuse-http + keys: + - 0x55A0B34D49501BB7CA474F5AA193FBB572174FC2 + +targets: + lxc: + create-message: | + You just created an {{ image.description }} container. + config: + - type: all + before: 5 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/opensuse.common.conf + + - type: user + before: 5 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/opensuse.userns.conf + + - type: all + after: 4 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/common.conf + + - type: user + after: 4 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/userns.conf + + - type: all + content: |- + lxc.arch = {{ image.architecture_kernel }} + +files: +- path: /etc/hostname + generator: hostname + +- path: /etc/hosts + generator: hosts + +- path: /etc/machine-id + generator: dump + +- path: /var/lib/dbus/machine-id + generator: remove + +- name: ifcfg-eth0 + path: /etc/sysconfig/network/ifcfg-eth0 + generator: dump + content: |- + STARTMODE='auto' + BOOTPROTO='dhcp' + types: + - container + +- name: meta-data + generator: cloud-init + variants: + - cloud + +- name: network-config + generator: cloud-init + variants: + - cloud + +- name: user-data + generator: cloud-init + variants: + - cloud + +- name: vendor-data + generator: cloud-init + variants: + - cloud + +- path: /etc/fstab + generator: dump + content: "# empty fstab to silence cloud-init warnings" + types: + - container + variants: + - cloud + +packages: + manager: zypper + update: true + cleanup: true + sets: + - packages: + - apparmor-abstractions + - apparmor-parser + - dbus-1 + - elfutils + - file + - glib2-tools + - gzip + - hardlink + - hostname + - iproute2 + - iputils + - pigz + - systemd-sysvinit + - tar + - which + - xz + - nano + action: install + + - packages: + - net-tools + releases: + - tumbleweed + action: install + + - packages: + - cloud-init + - cloud-init-config-suse + action: install + variants: + - cloud + +actions: +- trigger: post-packages + action: |- + #!/bin/sh + set -eux + + # Have the sysconfig network renderer support openSUSE Tumbleweed + sed -i "s|'opensuse'|'opensuse-tumbleweed'|" $(find /usr -wholename '*/cloudinit/net/sysconfig.py') + releases: + - tumbleweed + variants: + - cloud + +- trigger: post-packages + action: |- + #!/bin/sh + set -eux + + # Enable the cloud-init systemd service + systemctl enable cloud-init.service cloud-config.service cloud-final.service + variants: + - cloud + +- trigger: post-packages + action: |- + #!/bin/sh + umount -l /etc/resolv.conf || true + rm /etc/resolv.conf + ln -sf /var/run/netconfig/resolv.conf /etc/resolv.conf \ No newline at end of file diff --git a/opnsuse-Leap.yaml b/opnsuse-Leap.yaml new file mode 100644 index 0000000..e07612f --- /dev/null +++ b/opnsuse-Leap.yaml @@ -0,0 +1,137 @@ +image: + distribution: openSUSE + +source: + downloader: opensuse-http + url: http://192.168.2.83:8181/OpenSuse/ + keys: + - 0x55A0B34D49501BB7CA474F5AA193FBB572174FC2 + +targets: + lxc: + create-message: | + You just created an {{ image.description }} container. + config: + - type: all + before: 5 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/opensuse.common.conf + + - type: user + before: 5 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/opensuse.userns.conf + + - type: all + after: 4 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/common.conf + + - type: user + after: 4 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/userns.conf + + - type: all + content: |- + lxc.arch = {{ image.architecture_kernel }} + +files: +- path: /etc/hostname + generator: hostname + +- path: /etc/hosts + generator: hosts + +- path: /etc/machine-id + generator: dump + +- path: /var/lib/dbus/machine-id + generator: remove + +- name: ifcfg-eth0 + path: /etc/sysconfig/network/ifcfg-eth0 + generator: dump + content: |- + STARTMODE='auto' + BOOTPROTO='dhcp' + types: + - container + +- name: ifcfg-eth0 + path: /etc/sysconfig/network/ifcfg-eth0 + generator: dump + content: |- + STARTMODE='auto' + BOOTPROTO='dhcp' + types: + - container + +packages: + manager: zypper + update: true + cleanup: true + sets: + - packages: + - apparmor-abstractions + - apparmor-parser + - dbus-1 + - elfutils + - file + - glib2-tools + - gzip + - hardlink + - hostname + - iproute2 + - iputils + - pigz + - systemd-sysvinit + - tar + - which + - xz + action: install + - packages: + - nano + action: install + variants: + - default + + repositories: + - name: 2.x-repo-oss + url: http://192.168.2.83/opensuse/distribution/leap/$releasever/repo/oss/ + + - name: 2.x-repo-update + url: http://192.168.2.83/opensuse/update/leap/$releasever/oss/ + + - name: 2.x-repo-non-oss + url: http://192.168.2.83/opensuse/distribution/leap/$releasever/repo/non-oss/ + + - name: 2.x-repo-update-non-oss + url: http://192.168.2.83/opensuse/update/leap/$releasever/non-oss/ + + - name: 200.x-repo-oss + url: http://192.168.200.60/opensuse/distribution/leap/$releasever/repo/oss/ + + - name: 200.x-repo-update + url: http://192.168.2.83/opensuse/update/leap/$releasever/oss/ + + - name: 200.x-repo-non-oss + url: http://192.168.2.83/opensuse/distribution/leap/$releasever/repo/non-oss/ + + - name: 200.x-repo-update-non-oss + url: http://192.168.2.83/opensuse/update/leap/$releasever/non-oss/ + + +actions: +- trigger: post-unpack + action: |- + #!/bin/sh + zypper modifyrepo -d repo-{oss,non-oss,update,update-non-oss} + zypper modifyrepo -d 200.x-repo-{oss,non-oss,update,update-non-oss} + +- trigger: post-packages + action: |- + #!/bin/sh + umount -l /etc/resolv.conf || true + rm /etc/resolv.conf + ln -sf /var/run/netconfig/resolv.conf /etc/resolv.conf \ No newline at end of file