From 4030a1a7307492742387d2b7b00f8da933a810f4 Mon Sep 17 00:00:00 2001 From: Mat Sutcliffe Date: Mon, 29 Jul 2019 12:43:31 +0100 Subject: [PATCH] [Jenkinsfile] Check that submodules contain a branch pointing to HEAD with the same name as the superproject branch. --- Jenkinsfile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 58fbbebe6..2af4e8948 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,6 +5,7 @@ regexStableBranch = /stable\/\d+\.\d+/ regexTestingBranch = /testing\/.+/ regexNocacheBranch = /nocache\/.+/ regexRecacheBranches = [regexDevBranch] +regexSubmodBranches = [regexDevBranch, regexStableBranch] if (env.BRANCH_NAME && regexRecacheBranches.any{ env.BRANCH_NAME ==~ it }) { env.CCACHE_RECACHE = 1 @@ -22,6 +23,24 @@ properties([buildDiscarder(logRotator(numToKeepStr: '4'))]) def builders = [:] def buildResults = [:] +node('master') { + try { + stage('SCM Sanity Check') { + if (env.BRANCH_NAME && regexSubmodBranches.any{ env.BRANCH_NAME ==~ it }) { + checkout scm + def mods = sh(returnStdout: true, + script: "git submodule foreach -q 'git branch -r --points-at HEAD origin/${env.BRANCH_NAME} | read unused || basename \$name'") + if (!mods.isEmpty()) { error "${env.BRANCH_NAME} branch in submodules missing or not pointing to HEAD: \n${mods}" } + } + } + } catch(error) { + echo error.getMessage() + throw error + } finally { + cleanWs deleteDirs: true, notFailBuild: true + } +} + // Create a map to pass in to the 'parallel' step so we can fire all the builds at once builders['Build swift Linux'] = { node('linux') {