#!/usr/bin/env groovy /* Copyright (C) 2018, 2019 Collabora Limited Author: Guillaume Tucker This module is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* ---------------------------------------------------------------------------- * Jenkins parameters The following parameters need to be defined in the Jenkins pipeline job, with typical default values in brackets: CONFIG_LIST List of build configs to check instead of all the ones in build-configs.yaml KCI_API_URL (https://api.kernelci.org) URL of the KernelCI backend API KCI_TOKEN_ID Identifier of the KernelCI backend API token stored in Jenkins KCI_STORAGE_URL (https://storage.kernelci.org/) URL of the KernelCI storage server KCI_CORE_URL (https://github.com/kernelci/kernelci-core.git) URL of the kernelci-core repository KCI_CORE_BRANCH (master) Name of the branch to use in the kernelci-core repository DOCKER_BASE (kernelci/build-) Dockerhub base address used for the build images */ @Library('kernelci') _ import org.kernelci.util.Job def checkConfig(config, kci_core, trees_dir) { def commit = sh( script: """ ${kci_core}/kci_build \ --build-configs=${kci_core}/build-configs.yaml \ check_new_commit \ --config=${config} \ --storage=${params.KCI_STORAGE_URL} \ """, returnStdout: true).trim() if (!commit) { print("${config}: no new commit") return } print("${config}: triggering build") def job = "kernel-build-trigger" def str_params = [ 'BUILD_CONFIG': config, ] def job_params = [] def j = new Job() j.addStrParams(job_params, str_params) build(job: job, parameters: job_params, propagate: false, wait: false) } node("docker && monitor") { def j = new Job() def kci_core = env.WORKSPACE + '/kernelci-core' def trees_dir = "${env.WORKSPACE}/trees" def docker_image = "${params.DOCKER_BASE}base" print("""\ Storage: ${params.KCI_STORAGE_URL} Container: ${docker_image}""") j.dockerPullWithRetry(docker_image).inside() { stage("Init") { timeout(time: 15, unit: 'MINUTES') { j.cloneKciCore( kci_core, params.KCI_CORE_URL, params.KCI_CORE_BRANCH) } } stage("Monitor") { dir(kci_core) { def config_list = null def config_jobs = [:] if (params.CONFIG_LIST != "") { config_list = params.CONFIG_LIST.tokenize(' ') } else { def raw_configs = sh(script: "./kci_build list_configs", returnStdout: true).trim() config_list = raw_configs.tokenize('\n') } for (String config: config_list) { def config_name = config config_jobs[config_name] = { checkConfig(config_name, kci_core, trees_dir) } } parallel(config_jobs) } } } }