From 966907b2c692875fdb384f46e52a32fe92270448 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 20 Mar 2020 18:14:50 +0100 Subject: [PATCH] Moved verify changes to shared libraries. --- Jenkinsfile | 74 ++++++++--------------------------------------------- 1 file changed, 10 insertions(+), 64 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c01d34087a8..ce680e388da 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,13 +2,13 @@ import org.stan.Utils def utils = new org.stan.Utils() +def skipRemainingStages = false def setupCXX(failOnError = true) { errorStr = failOnError ? "-Werror " : "" writeFile(file: "make/local", text: "CXX=${env.CXX} ${errorStr}") } - def runTests(String testPath, Boolean separateMakeStep=true) { if (separateMakeStep) { sh "./runTests.py -j${env.PARALLEL} ${testPath} --make-only" @@ -30,24 +30,6 @@ def deleteDirWin() { deleteDir() } -def sourceCodePaths(){ - // These paths will be passed to git diff - // If there are changes to them, CI/CD will continue else skip - def paths = ['make', 'src/stan', 'src/test', 'Jenkinsfile', 'makefile', 'runTests.py', - 'lib/stan_math/stan', 'lib/stan_math/make', 'lib/stan_math/lib', 'lib/stan_math/test', - 'lib/stan_math/runTests.py', 'lib/stan_math/runChecks.py', 'lib/stan_math/makefile', - 'lib/stan_math/Jenkinsfile', 'lib/stan_math/.clang-format' - ] - - def bashArray = "" - - for(path in paths){ - bashArray += path + (path != paths[paths.size() - 1] ? " " : "") - } - - return bashArray -} - String cmdstan_pr() { params.cmdstan_pr ?: "downstream_tests" } String stan_pr() { if (env.BRANCH_NAME == 'downstream_tests') { @@ -73,9 +55,6 @@ pipeline { string(defaultValue: 'downstream_tests', name: 'cmdstan_pr', description: 'PR to test CmdStan upstream against e.g. PR-630') } - environment { - scPaths = sourceCodePaths() - } options { skipDefaultCheckout() preserveStashes(buildCount: 7) @@ -188,48 +167,15 @@ pipeline { retry(3) { checkout scm } sh 'git clean -xffd' - def commitHash = sh(script: "git rev-parse HEAD | tr '\\n' ' '", returnStdout: true) - def changeTarget = "" - - if (env.CHANGE_TARGET) { - println "This build is a PR, checking out target branch to compare changes." - changeTarget = env.CHANGE_TARGET - sh(script: "git pull && git checkout ${changeTarget}", returnStdout: false) - } - else{ - println "This build is not PR, checking out current branch and extract HEAD^1 commit to compare changes or develop when downstream_tests." - if (env.BRANCH_NAME == "downstream_tests"){ - sh(script: "git checkout develop && git pull", returnStdout: false) - changeTarget = sh(script: "git rev-parse HEAD^1 | tr '\\n' ' '", returnStdout: true) - sh(script: "git checkout ${commitHash}", returnStdout: false) - } - else{ - sh(script: "git pull && git checkout ${env.BRANCH_NAME}", returnStdout: false) - changeTarget = sh(script: "git rev-parse HEAD^1 | tr '\\n' ' '", returnStdout: true) - } - } - - println "Comparing differences between current ${commitHash} and target ${changeTarget}." - - def bashScript = """ - for i in ${env.scPaths}; - do - git diff ${commitHash} ${changeTarget} -- \$i - done - """ - - def differences = sh(script: bashScript, returnStdout: true) + // These paths will be passed to git diff + // If there are changes to them, CI/CD will continue else skip + def paths = ['make', 'src/stan', 'src/test', 'Jenkinsfile', 'makefile', 'runTests.py', + 'lib/stan_math/stan', 'lib/stan_math/make', 'lib/stan_math/lib', 'lib/stan_math/test', + 'lib/stan_math/runTests.py', 'lib/stan_math/runChecks.py', 'lib/stan_math/makefile', + 'lib/stan_math/Jenkinsfile', 'lib/stan_math/.clang-format' + ].join(" ") - println differences - - if (differences?.trim()) { - println "There are differences in the source code, CI/CD will run." - skipRemainingStages = false - } - else{ - println "There aren't any differences in the source code, CI/CD will not run." - skipRemainingStages = true - } + skipRemainingStages = utils.verifyChanges(paths) } } post { @@ -352,4 +298,4 @@ pipeline { unstable { script { utils.mailBuildResults("UNSTABLE", "stan-buildbot@googlegroups.com") } } failure { script { utils.mailBuildResults("FAILURE", "stan-buildbot@googlegroups.com") } } } -} +} \ No newline at end of file