Perform Jenkins builds in /dash-src all the time to fix caching issues (#2242)

This commit is contained in:
Alexander Block 2018-08-29 12:03:18 +02:00 committed by UdjinM6
parent 40eee1775f
commit 799e3c3126

54
Jenkinsfile vendored
View File

@ -25,11 +25,29 @@ for(int i = 0; i < targets.size(); i++) {
def UID = sh(returnStdout: true, script: 'id -u').trim()
def HOME = sh(returnStdout: true, script: 'echo $HOME').trim()
def pwd = sh(returnStdout: true, script: 'pwd').trim()
def hasCache = false
checkout scm
def env = [
"BUILD_TARGET=${target}",
"PULL_REQUEST=false",
"JOB_NUMBER=${BUILD_NUMBER}",
]
withEnv(env) {
def builderImageName="dash-builder-${target}"
def builderImage
stage("${target}/builder-image") {
builderImage = docker.build("${builderImageName}", "--build-arg BUILD_TARGET=${target} ci -f ci/Dockerfile.builder")
}
builderImage.inside("-t") {
// copy source into fixed path
// we must build under the same path everytime as otherwise caches won't work properly
sh "cp -ra ${pwd}/. /dash-src/"
// restore cache
def hasCache = false
try {
copyArtifacts(projectName: "dashpay-dash/${BRANCH_NAME}", optional: true, selector: lastSuccessful(), filter: "ci-cache-${target}.tar.gz")
} catch (Exception e) {
@ -48,42 +66,30 @@ for(int i = 0; i < targets.size(); i++) {
}
}
def env = [
"BUILD_TARGET=${target}",
"PULL_REQUEST=false",
"JOB_NUMBER=${BUILD_NUMBER}",
]
withEnv(env) {
def builderImageName="dash-builder-${target}"
def builderImage
stage("${target}/builder-image") {
builderImage = docker.build("${builderImageName}", "--build-arg BUILD_TARGET=${target} ci -f ci/Dockerfile.builder")
}
if (hasCache) {
sh "cd ${pwd} && tar xzfv ci-cache-${target}.tar.gz"
sh "cd /dash-src && tar xzf ${pwd}/ci-cache-${target}.tar.gz"
} else {
sh "mkdir -p ${pwd}/ci-cache-${target}"
sh "mkdir -p /dash-src/ci-cache-${target}"
}
builderImage.inside("-t") {
stage("${target}/depends") {
sh './ci/build_depends.sh'
sh 'cd /dash-src && ./ci/build_depends.sh'
}
stage("${target}/build") {
sh './ci/build_src.sh'
sh 'cd /dash-src && ./ci/build_src.sh'
}
stage("${target}/test") {
sh './ci/test_unittests.sh'
sh 'cd /dash-src && ./ci/test_unittests.sh'
}
stage("${target}/test") {
sh './ci/test_integrationtests.sh'
}
sh 'cd /dash-src && ./ci/test_integrationtests.sh'
}
// archive cache
sh "tar czfv ci-cache-${target}.tar.gz ci-cache-${target}"
// archive cache and copy it into the jenkins workspace
sh "cd /dash-src && tar czfv ci-cache-${target}.tar.gz ci-cache-${target} && cp ci-cache-${target}.tar.gz ${pwd}/"
}
// upload cache
archiveArtifacts artifacts: "ci-cache-${target}.tar.gz", fingerprint: true
}
}