summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docker/Dockerfile7
-rw-r--r--packages/vyos-build-container/Jenkinsfile69
-rwxr-xr-xpackages/vyos-build-container/build.sh24
-rw-r--r--vars/buildPackage.groovy23
-rw-r--r--vars/isCustomBuild.groovy4
5 files changed, 123 insertions, 4 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
index be789fc2..a9336665 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -357,6 +357,13 @@ RUN apt-get update && apt-get install -y \
RUN apt-get update && apt-get install -y \
asciidoc-base
+# Extra packages
+RUN apt-get update
+# For owamp
+RUN apt-get install -y dh-apparmor dh-exec libcap-dev
+# For vyos-xe-guest-utilities
+RUN apt-get install -y golang gawk
+
# Allow password-less 'sudo' for all users in group 'sudo'
RUN sed "s/^%sudo.*/%sudo\tALL=(ALL) NOPASSWD:ALL/g" -i /etc/sudoers && \
echo "vyos_bld\tALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
diff --git a/packages/vyos-build-container/Jenkinsfile b/packages/vyos-build-container/Jenkinsfile
new file mode 100644
index 00000000..685dbfc2
--- /dev/null
+++ b/packages/vyos-build-container/Jenkinsfile
@@ -0,0 +1,69 @@
+// Copyright (C) 2020-2024 VyOS maintainers and contributors
+//
+// This program is free software; you can redistribute it and/or modify
+// in order to easy exprort images built to 'external' world
+// it under the terms of the GNU General Public License version 2 or later as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+@NonCPS
+
+// Using a version specifier library, use 'current' branch. The underscore (_)
+// is not a typo! You need this underscore if the line immediately after the
+// @Library annotation is not an import statement!
+@Library('vyos-build@current')_
+
+pipeline {
+ agent none
+ options {
+ disableConcurrentBuilds()
+ timeout(time: 240, unit: 'MINUTES')
+ timestamps()
+ buildDiscarder(logRotator(numToKeepStr: '10'))
+ }
+ stages {
+ stage('Build') {
+ agent {
+ label "ec2_amd64"
+ }
+ when {
+ anyOf {
+ changeset pattern: "**/docker/*", caseSensitive: true
+ triggeredBy cause: "UserIdCause"
+ }
+ }
+ steps {
+ script {
+ // Checkout git repository which hold 'Jenkinsfile'
+ checkout scm
+
+ // Display Git commit Id used with the Jenkinsfile on the Job 'Build History' pane
+ def commitId = sh(returnStdout: true, script: 'git rev-parse --short=11 HEAD').trim()
+ currentBuild.description = 'Git SHA1: ' + commitId
+
+ // Fetch sources and build docker image
+ dir(getJenkinsfilePath() + 'vyos-build') {
+ checkout([$class: 'GitSCM',
+ doGenerateSubmoduleConfigurations: false,
+ extensions: [[$class: 'CleanCheckout']],
+ branches: [[name: env.BRANCH_NAME]],
+ userRemoteConfigs: [[url: 'https://github.com/dd010101/vyos-build.git']]])
+
+ sh 'cd ..; ./build.sh'
+ }
+ }
+ }
+ post {
+ cleanup {
+ deleteDir()
+ }
+ }
+ }
+ }
+}
diff --git a/packages/vyos-build-container/build.sh b/packages/vyos-build-container/build.sh
new file mode 100755
index 00000000..5a526220
--- /dev/null
+++ b/packages/vyos-build-container/build.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+set -e
+
+cd vyos-build/docker
+
+echo "Inspecting current image of ${BRANCH_NAME}..."
+previousImageId=$(docker images --filter=reference="vyos/vyos-build:${BRANCH_NAME}" --format "{{.ID}}")
+
+echo "Building docker build container for branch ${BRANCH_NAME}..."
+docker build --no-cache -t "vyos/vyos-build:${BRANCH_NAME}" .
+
+echo "Pushing ${BRANCH_NAME} image to registry ${CUSTOM_DOCKER_REPO}..."
+docker tag "vyos/vyos-build:${BRANCH_NAME}" "${CUSTOM_DOCKER_REPO}/vyos/vyos-build:${BRANCH_NAME}"
+docker push "${CUSTOM_DOCKER_REPO}/vyos/vyos-build:$BRANCH_NAME"
+
+echo "Cleaning previous image of ${BRANCH_NAME}..."
+if [ "$previousImageId" != "" ]; then
+ docker rmi --force "$previousImageId" || true
+fi
+
+echo "Cleaning local registry..."
+docker exec registry registry garbage-collect /etc/docker/registry/config.yml --delete-untagged=true
+
+echo "Image ${BRANCH_NAME} was successfully built and pushed to registry ${CUSTOM_DOCKER_REPO}."
diff --git a/vars/buildPackage.groovy b/vars/buildPackage.groovy
index 531e51d9..239ab465 100644
--- a/vars/buildPackage.groovy
+++ b/vars/buildPackage.groovy
@@ -115,7 +115,13 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP
}
}
when {
- equals expected: true, actual: buildArm
+ beforeAgent true
+ allOf {
+ expression {
+ return env.ARM64_BUILD_DISABLED != 'true'
+ }
+ equals expected: true, actual: buildArm
+ }
}
steps {
script {
@@ -202,7 +208,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP
}
}
- files = findFiles(glob: '**/*.deb')
+ files = findFiles(glob: '**/*.deb', excludes: '**/Makefile.deb')
if (files) {
echo "Remove deprecated binary package(s) from the repository..."
files.each { FILE ->
@@ -235,7 +241,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP
}
}
- files = findFiles(glob: '**/*.deb')
+ files = findFiles(glob: '**/*.deb', excludes: '**/Makefile.deb')
if (files) {
echo "Uploading binary package(s) to the repository ..."
files.each { FILE ->
@@ -245,11 +251,20 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP
def ARCH = ''
if (PACKAGE_ARCH != 'all')
ARCH = '-A ' + PACKAGE_ARCH
+ def EXTRA_ARGS = ''
+ // Add generic Priority if missing
+ if (sh(returnStatus: true, script: "dpkg-deb -f ${FILE} | grep Priority:") != 0) {
+ EXTRA_ARGS = EXTRA_ARGS + ' -P optional'
+ }
+ // Add generic Section if missing
+ if (sh(returnStatus: true, script: "dpkg-deb -f ${FILE} | grep Section:") != 0) {
+ EXTRA_ARGS = EXTRA_ARGS + ' -S misc'
+ }
sh(script: "scp ${SSH_OPTS} ${FILE} ${SSH_REMOTE}:${SSH_DIR}")
// Packages like FRR produce their binary in a nested path e.g. packages/frr/frr-rpki-rtrlib-dbgsym_7.5_arm64.deb,
// thus we will only extract the filename portion from FILE as the binary is scp'ed to SSH_DIR without any subpath.
def FILENAME = FILE.toString().tokenize('/').last()
- sh(script: "ssh ${SSH_OPTS} ${SSH_REMOTE} -t \"uncron-add 'reprepro -v -b ${VYOS_REPO_PATH} ${ARCH} includedeb ${RELEASE} ${SSH_DIR}/${FILENAME}'\"")
+ sh(script: "ssh ${SSH_OPTS} ${SSH_REMOTE} -t \"uncron-add 'reprepro -v -b ${VYOS_REPO_PATH}${EXTRA_ARGS} ${ARCH} includedeb ${RELEASE} ${SSH_DIR}/${FILENAME}'\"")
}
sh(script: "ssh ${SSH_OPTS} ${SSH_REMOTE} -t \"uncron-add 'reprepro -v -b ${VYOS_REPO_PATH} deleteunreferenced'\"")
}
diff --git a/vars/isCustomBuild.groovy b/vars/isCustomBuild.groovy
index c5e5fab7..b1e6fe76 100644
--- a/vars/isCustomBuild.groovy
+++ b/vars/isCustomBuild.groovy
@@ -22,5 +22,9 @@ def call() {
def gitURI = 'git@github.com:vyos/' + getGitRepoName()
def httpURI = 'https://github.com/vyos/' + getGitRepoName()
+ if (env.CUSTOM_BUILD_CHECK_DISABLED) {
+ return false
+ }
+
return !((getGitRepoURL() == gitURI) || (getGitRepoURL() == httpURI)) || isPullRequest()
}