Updated CI to run some things in parallel

This commit is contained in:
Jamie Curnow 2024-01-09 10:05:19 +10:00
parent e4ef095254
commit f7c87f63bd
No known key found for this signature in database
GPG Key ID: FFBB624C43388E9E

105
Jenkinsfile vendored
View File

@ -60,27 +60,43 @@ pipeline {
} }
} }
} }
stage('Build and Test') { stage('Builds') {
steps { parallel {
script { stage('Project') {
// Frontend and Backend steps {
def shStatusCode = sh(label: 'Checking and Building', returnStatus: true, script: ''' script {
set -e // Frontend and Backend
./scripts/ci/frontend-build > ${WORKSPACE}/tmp-sh-build 2>&1 def shStatusCode = sh(label: 'Checking and Building', returnStatus: true, script: '''
./scripts/ci/test-and-build > ${WORKSPACE}/tmp-sh-build 2>&1 set -e
''') ./scripts/ci/frontend-build > ${WORKSPACE}/tmp-sh-build 2>&1
shOutput = readFile "${env.WORKSPACE}/tmp-sh-build" ./scripts/ci/test-and-build > ${WORKSPACE}/tmp-sh-build 2>&1
if (shStatusCode != 0) { ''')
error "${shOutput}" shOutput = readFile "${env.WORKSPACE}/tmp-sh-build"
if (shStatusCode != 0) {
error "${shOutput}"
}
}
}
post {
always {
sh 'rm -f ${WORKSPACE}/tmp-sh-build'
}
failure {
npmGithubPrComment("CI Error:\n\n```\n${shOutput}\n```", true)
}
} }
} }
} stage('Docs') {
post { steps {
always { dir(path: 'docs') {
sh 'rm -f ${WORKSPACE}/tmp-sh-build' sh 'yarn install'
} sh 'yarn build'
failure { }
npmGithubPrComment("CI Error:\n\n```\n${shOutput}\n```", true) dir(path: 'docs/.vuepress/dist') {
sh 'tar -czf ../../docs.tgz *'
}
archiveArtifacts(artifacts: 'docs/docs.tgz', allowEmptyArchive: false)
}
} }
} }
} }
@ -140,25 +156,6 @@ pipeline {
} }
} }
} }
stage('Docs') {
when {
not {
equals expected: 'UNSTABLE', actual: currentBuild.result
}
}
steps {
dir(path: 'docs') {
sh 'yarn install'
sh 'yarn build'
}
dir(path: 'docs/.vuepress/dist') {
sh 'tar -czf ../../docs.tgz *'
}
archiveArtifacts(artifacts: 'docs/docs.tgz', allowEmptyArchive: false)
}
}
stage('MultiArch Build') { stage('MultiArch Build') {
when { when {
not { not {
@ -172,9 +169,9 @@ pipeline {
} }
} }
} }
stage('Docs Deploy') { stage('Docs / Comment') {
parallel { parallel {
stage('Master') { stage('Master Docs') {
when { when {
allOf { allOf {
branch 'master' branch 'master'
@ -187,7 +184,7 @@ pipeline {
npmDocsReleaseMaster() npmDocsReleaseMaster()
} }
} }
stage('Develop') { stage('Develop Docs') {
when { when {
allOf { allOf {
branch 'develop' branch 'develop'
@ -200,20 +197,20 @@ pipeline {
npmDocsReleaseDevelop() npmDocsReleaseDevelop()
} }
} }
} stage('PR Comment') {
} when {
stage('PR Comment') { allOf {
when { changeRequest()
allOf { not {
changeRequest() equals expected: 'UNSTABLE', actual: currentBuild.result
not { }
equals expected: 'UNSTABLE', actual: currentBuild.result }
}
steps {
script {
npmGithubPrComment("Docker Image for build ${BUILD_NUMBER} is available on [DockerHub](https://cloud.docker.com/repository/docker/jc21/${IMAGE}) as `jc21/${IMAGE}:github-${BRANCH_LOWER}`\n\n**Note:** ensure you backup your NPM instance before testing this PR image! Especially if this PR contains database changes.", true)
}
} }
}
}
steps {
script {
npmGithubPrComment("Docker Image for build ${BUILD_NUMBER} is available on [DockerHub](https://cloud.docker.com/repository/docker/jc21/${IMAGE}) as `jc21/${IMAGE}:github-${BRANCH_LOWER}`\n\n**Note:** ensure you backup your NPM instance before testing this PR image! Especially if this PR contains database changes.", true)
} }
} }
} }