From 63493afa4c9cb05cdf7318b841edf52ad0779014 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 9 Apr 2019 20:15:57 +0200 Subject: Replace build-submodules with Python based package builder Support building individual VyOS packages by this modules. Call scripts/build-packages -l to list all available packages which will be build when invoking scripts/build-packages. --- Jenkinsfile | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 116 insertions(+), 14 deletions(-) (limited to 'Jenkinsfile') diff --git a/Jenkinsfile b/Jenkinsfile index 4bc64b26..169a52f3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,22 +1,76 @@ #!/usr/bin/env groovy +// Copyright (C) 2018 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 . + @NonCPS + +def getGitBranchName() { + return scm.branches[0].name +} + +def getGitRepoURL() { + return scm.userRemoteConfigs[0].url +} + +// Returns true if this is a custom build launched on any project fork, +// returns false if this is build from git@github.com:vyos/vyos-build.git +def isCustomBuild() { + def gitURI = "git@github.com:vyos/vyos-build.git" + def httpURI = "https://github.com/vyos/vyos-build.git" + + return ! ((getGitRepoURL() == gitURI) || (getGitRepoURL() == httpURI)) +} + def setDescription() { def item = Jenkins.instance.getItemByFullName(env.JOB_NAME) - item.setDescription("VyOS image build using a\nPipeline build inside Docker container.") + + // build up the main description text + def description = "" + description += "

Build VyOS ISO image

" + description += "All required Vyatta/VyOS packages are build from source prior to assembling the ISO." + + if (isCustomBuild()) { + description += "

" + description += "Build not started from official Git repository!
" + description += "
" + description += "Repository: " + getGitRepoURL() + "
" + description += "Branch: " + getGitBranchName() + "
" + description += "

" + } else { + description += "Sources taken from Git branch: " + getGitBranchName() + "
" + } + + item.setDescription(description) item.save() } -setDescription() - /* Only keep the 10 most recent builds. */ def projectProperties = [ - [$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '5']], + [$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '1']], ] properties(projectProperties) +setDescription() pipeline { + options { + disableConcurrentBuilds() + timeout(time: 4, unit: 'HOURS') + parallelsAlwaysFailFast() + } agent { dockerfile { filename 'Dockerfile' @@ -27,23 +81,71 @@ pipeline { } stages { - stage('Submodule Init') { + stage('VyOS Packages') { steps { - sh ''' - git submodule update --init --recursive --remote - ''' + script { + def build = [:] + // get a list of available package from scripts/build-packages + packageList = sh( + script: "scripts/build-packages -l | grep '*' | sed -e 's/ \\* //'", + returnStdout: true + ).split("\r?\n") + + packageList.each { pkg -> + skipList = ['vyos-kernel', 'vyos-wireguard', 'vyos-accel-ppp'] + if (pkg in skipList) { + return + } + + // add each object from 'packageList' to the 'build' array + build[pkg] = { + // we're already in the script{} block, so do our advanced stuff here + sh( + script: "scripts/build-packages -vvv -b ${pkg}", + returnStdout: true + ) + } + } + // Still within the 'Script' block, run the parallel array object + parallel build + } } } - stage('Build Packages') { + + stage('Kernel') { steps { - sh ''' - #!/bin/sh - scripts/build-submodules --verbose - ''' + sh "scripts/build-packages -vvv -b vyos-kernel" + } + } + + stage('Kernel Modules') { + steps { + script { + def build = [:] + kernelModules = ['vyos-wireguard', 'vyos-accel-ppp'] + kernelModules.each { pkg -> + // add each object from 'packageList' to the 'build' array + build[pkg] = { + // we're already in the script{} block, so do our advanced stuff here + sh( + script: "scripts/build-packages -vvv -b ${pkg}", + returnStdout: true + ) + } + } + // Still within the 'Script' block, run the parallel array object + parallel build + } + } + } + + stage('Intel Drivers') { + steps { + sh "KSRC=\$(pwd)/packages/vyos-kernel scripts/build-intel-drivers" } } - stage('Build ISO') { + stage('ISO Image') { steps { sh ''' #!/bin/sh -- cgit v1.2.3