Unverified Commit 94f976b8 authored by Maxim Cournoyer's avatar Maxim Cournoyer
Browse files

Jenkinsfile: Add the ability to opt out of updating submodules.

* Jenkinsfile (submodules): New variable.
[parameters]{WITH_MANUAL_SUBMODULES}: New parameter.
(Fetch submodules): Adapt the message to the parameter's value.  Add
the '--remote' option to 'git submodule' unless WITH_MANUAL_SUBMODULES
is true.

GitLab: jami-packaging#98
Change-Id: Ie5f0521bed16303e751e8e19174f18a90bccefcc
parent 854d54ba
...@@ -3,6 +3,14 @@ ...@@ -3,6 +3,14 @@
// Note: To work on this script without having to push a commit each // Note: To work on this script without having to push a commit each
// time, use the jenkins-cli command (see: // time, use the jenkins-cli command (see:
// https://wiki.savoirfairelinux.com/wiki/Jenkins.jami.net#Usage_CLI_de_Jenkins). // https://wiki.savoirfairelinux.com/wiki/Jenkins.jami.net#Usage_CLI_de_Jenkins).
//
// Requirements:
// 1. gerrit-trigger plugin
// 2. ws-cleanup plugin
// Configuration globals.
def SUBMODULES = ['daemon', 'lrc', 'client-gnome', 'client-qt']
pipeline { pipeline {
agent { agent {
label 'guix' label 'guix'
...@@ -12,6 +20,12 @@ pipeline { ...@@ -12,6 +20,12 @@ pipeline {
string(name: 'GERRIT_REFSPEC', string(name: 'GERRIT_REFSPEC',
defaultValue: 'refs/heads/master', defaultValue: 'refs/heads/master',
description: 'The Gerrit refspec to fetch.') description: 'The Gerrit refspec to fetch.')
booleanParam(name: 'WITH_MANUAL_SUBMODULES',
defaultValue: false,
description: 'Checkout the ' + SUBMODULES.join(', ') +
' submodules at their Git-recorded commit. When left ' +
'unticked (the default), checkout the submodules at ' +
'their latest commit from their main remote branch.')
booleanParam(name: 'BUILD_OWN_QT', booleanParam(name: 'BUILD_OWN_QT',
defaultValue: false, defaultValue: false,
description: 'Whether to build our own Qt packages.') description: 'Whether to build our own Qt packages.')
...@@ -45,9 +59,11 @@ See https://wiki.savoirfairelinux.com/wiki/Jenkins.jami.net#Configuration" ...@@ -45,9 +59,11 @@ See https://wiki.savoirfairelinux.com/wiki/Jenkins.jami.net#Configuration"
stage('Fetch submodules') { stage('Fetch submodules') {
steps { steps {
echo 'Updating relevant submodules to their latest commit' echo 'Initializing submodules ' + SUBMODULES.join(', ') +
sh 'git submodule update --init --recursive --remote ' + (params.WITH_MANUAL_SUBMODULES ? '.' : ' to their latest commit.')
'daemon lrc client-gnome client-qt' sh 'git submodule update --init --recursive' +
(params.WITH_MANUAL_SUBMODULES ? ' ' : ' --remote ') +
SUBMODULES.join(' ')
} }
} }
...@@ -79,21 +95,22 @@ See https://wiki.savoirfairelinux.com/wiki/Jenkins.jami.net#Configuration" ...@@ -79,21 +95,22 @@ See https://wiki.savoirfairelinux.com/wiki/Jenkins.jami.net#Configuration"
returnStdout: true).trim() returnStdout: true).trim()
} }
def targets = targetsText.split(/\s/) TARGETS = targetsText.split(/\s/)
if (!params.BUILD_OWN_QT) { if (!params.BUILD_OWN_QT) {
targets = targets.findAll { !it.endsWith('_qt') } TARGETS = TARGETS.findAll { !it.endsWith('_qt') }
} }
if (!params.BUILD_ARM) { if (!params.BUILD_ARM) {
targets = targets.findAll { !(it =~ /_(armhf|arm64)$/) } TARGETS = TARGETS.findAll { !(it =~ /_(armhf|arm64)$/) }
} }
def stages = [:] def stages = [:]
targets.each { target -> TARGETS.each { target ->
// Note: The stage calls are wrapped in closures, to // Note: The stage calls are wrapped in closures, to
// delay their execution. // delay their execution.
stages["${target}"] = { stages[target] = {
stage("${target}") { stage(target) {
// Offload builds to different agents. // Offload builds to different agents.
node('linux-builder') { node('linux-builder') {
cleanWs() cleanWs()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment