abstract changed files pattern to git.changedfiles()
move the logic related to changed files in commit check to canvas-builds refs DE-366 flag = none test plan: - Build passes - Main Build detect if there was a change in Jenkins file in HEAD - Local Docker dev Build is triggered if a local dev file changes - JENKINSFILE_REFSPEC is setted if a Jenkinfiles changes Change-Id: I497cae9654e1b71b2de5ec3325b9577b30cfeeba Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/253555 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Andrea Cirulli <andrea.cirulli@instructure.com> Product-Review: Andrea Cirulli <andrea.cirulli@instructure.com> Reviewed-by: Aaron Ogata <aogata@instructure.com> Reviewed-by: James Butters <jbutters@instructure.com>
This commit is contained in:
parent
d2d12971e7
commit
a06b159d06
|
@ -35,6 +35,22 @@ def buildParameters = [
|
||||||
string(name: 'MASTER_BOUNCER_RUN', value: "${env.MASTER_BOUNCER_RUN}")
|
string(name: 'MASTER_BOUNCER_RUN', value: "${env.MASTER_BOUNCER_RUN}")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def dockerDevFiles = [
|
||||||
|
'^docker-compose/',
|
||||||
|
'^build/common_docker_build_steps.sh',
|
||||||
|
'^script/canvas_update',
|
||||||
|
'^docker-compose.yml',
|
||||||
|
'^Dockerfile$',
|
||||||
|
'^lib/tasks/',
|
||||||
|
'Jenkinsfile.docker-smoke'
|
||||||
|
]
|
||||||
|
|
||||||
|
def jenkinsFiles = [
|
||||||
|
'Jenkinsfile*',
|
||||||
|
'^docker-compose.new-jenkins*.yml',
|
||||||
|
'build/new-jenkins/*'
|
||||||
|
]
|
||||||
|
|
||||||
def getDockerWorkDir() {
|
def getDockerWorkDir() {
|
||||||
return env.GERRIT_PROJECT == "canvas-lms" ? "/usr/src/app" : "/usr/src/app/gems/plugins/${env.GERRIT_PROJECT}"
|
return env.GERRIT_PROJECT == "canvas-lms" ? "/usr/src/app" : "/usr/src/app/gems/plugins/${env.GERRIT_PROJECT}"
|
||||||
}
|
}
|
||||||
|
@ -403,7 +419,7 @@ pipeline {
|
||||||
}
|
}
|
||||||
// If modifying any of our Jenkinsfiles set JENKINSFILE_REFSPEC for sub-builds to use Jenkinsfiles in
|
// If modifying any of our Jenkinsfiles set JENKINSFILE_REFSPEC for sub-builds to use Jenkinsfiles in
|
||||||
// the gerrit rather than master.
|
// the gerrit rather than master.
|
||||||
if(env.GERRIT_PROJECT == 'canvas-lms' && (sh(script: './build/new-jenkins/jenkinsfile_changes.sh', returnStatus: true) == 0)) {
|
if(env.GERRIT_PROJECT == 'canvas-lms' && git.changedFiles(jenkinsFiles, 'HEAD^') ) {
|
||||||
buildParameters += string(name: 'JENKINSFILE_REFSPEC', value: "${env.GERRIT_REFSPEC}")
|
buildParameters += string(name: 'JENKINSFILE_REFSPEC', value: "${env.GERRIT_REFSPEC}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,15 +472,8 @@ pipeline {
|
||||||
rebaseHelper("master")
|
rebaseHelper("master")
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!env.JOB_NAME.endsWith('Jenkinsfile')) {
|
if(!env.JOB_NAME.endsWith('Jenkinsfile') && git.changedFiles(jenkinsFiles, 'origin/master')) {
|
||||||
sh """#!/bin/bash
|
error "Jenkinsfile has been updated. Please retrigger your patchset for the latest updates."
|
||||||
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
|
|
||||||
|
|
||||||
if git diff --name-only origin/master..HEAD Jenkinsfile* docker-compose.new-jenkins* build/new-jenkins/* |grep -E "Jenkinsfile|docker-compose.new-jenkins|build/new-jenkins/"; then
|
|
||||||
echo "Jenkinsfile has been updated. Please retrigger your patchset for the latest updates."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,7 +646,7 @@ pipeline {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(env.GERRIT_PROJECT == 'canvas-lms' && (sh(script: 'build/new-jenkins/docker-dev-changes.sh', returnStatus: true) == 0)) {
|
if(env.GERRIT_PROJECT == 'canvas-lms' && git.changedFiles(dockerDevFiles, 'HEAD^')) {
|
||||||
echo 'adding Local Docker Dev Build'
|
echo 'adding Local Docker Dev Build'
|
||||||
buildStage.makeFromJob('Local Docker Dev Build', '/Canvas/test-suites/local-docker-dev-smoke', stages, buildParameters)
|
buildStage.makeFromJob('Local Docker Dev Build', '/Canvas/test-suites/local-docker-dev-smoke', stages, buildParameters)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -o nounset -o errexit -o errtrace -o pipefail -o xtrace
|
|
||||||
function join_by { local d=$1; shift; local f=$1; shift; printf %s "$f" "${@/#/$d}"; }
|
|
||||||
|
|
||||||
fileArr=(
|
|
||||||
'^docker-compose/'
|
|
||||||
'^build/common_docker_build_steps.sh'
|
|
||||||
'^script/canvas_update'
|
|
||||||
'^docker-compose.yml'
|
|
||||||
'^Dockerfile$'
|
|
||||||
'^lib/tasks/'
|
|
||||||
'Jenkinsfile.docker-smoke'
|
|
||||||
)
|
|
||||||
|
|
||||||
files=$(join_by '|' "${fileArr[@]}")
|
|
||||||
|
|
||||||
changed="$(git show --pretty="" --name-only HEAD^..HEAD | grep -E "${files}")"
|
|
||||||
|
|
||||||
[[ -n "$changed" ]]; exit $?
|
|
|
@ -1,21 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -o nounset -o errexit -o errtrace -o pipefail -o xtrace
|
|
||||||
function join_by { local d=$1; shift; local f=$1; shift; printf %s "$f" "${@/#/$d}"; }
|
|
||||||
|
|
||||||
fileArr=(
|
|
||||||
'^Jenkinsfile$'
|
|
||||||
'^Jenkinsfile.contract-tests$'
|
|
||||||
'^Jenkinsfile.docker-smoke$'
|
|
||||||
'^Jenkinsfile.js$'
|
|
||||||
'^Jenkinsfile.selenium.flakey_spec_catcher$'
|
|
||||||
'^Jenkinsfile.vendored-gems$'
|
|
||||||
'^docker-compose.new-jenkins*.yml'
|
|
||||||
'build/new-jenkins/*'
|
|
||||||
)
|
|
||||||
|
|
||||||
files=$(join_by '|' "${fileArr[@]}")
|
|
||||||
|
|
||||||
changed="$(git show --pretty="" --name-only HEAD^..HEAD | grep -E "${files}")"
|
|
||||||
|
|
||||||
[[ -n "$changed" ]]; exit $?
|
|
Loading…
Reference in New Issue