Bring CI in line with develop branch

This commit is contained in:
Jamie Curnow 2024-05-17 08:56:57 +10:00
parent 70cfbfb1b0
commit 52bd7b1d8f
No known key found for this signature in database
GPG Key ID: FFBB624C43388E9E

141
Jenkinsfile vendored
View File

@ -28,13 +28,11 @@ pipeline {
BUILD_VERSION = getVersion() BUILD_VERSION = getVersion()
BUILD_COMMIT = getCommit() BUILD_COMMIT = getCommit()
MAJOR_VERSION = '3' MAJOR_VERSION = '3'
BRANCH_LOWER = "${BRANCH_NAME.toLowerCase().replaceAll('/', '-')}" BRANCH_LOWER = "${BRANCH_NAME.toLowerCase().replaceAll('\\\\', '-').replaceAll('/', '-').replaceAll('\\.', '-')}"
COMPOSE_PROJECT_NAME = "npm_${BRANCH_LOWER}_${BUILD_NUMBER}" COMPOSE_PROJECT_NAME = "npm_${BRANCH_LOWER}_${BUILD_NUMBER}"
COMPOSE_FILE = 'docker/docker-compose.ci.yml' COMPOSE_FILE = 'docker/docker-compose.ci.yml'
COMPOSE_INTERACTIVE_NO_CLI = 1 COMPOSE_INTERACTIVE_NO_CLI = 1
BUILDX_NAME = "${COMPOSE_PROJECT_NAME}" BUILDX_NAME = "${COMPOSE_PROJECT_NAME}"
DOCS_BUCKET = 'jc21-npm-site-next' // TODO: change to prod when official
DOCS_CDN = 'E2Z0128EHS0Q23' // TODO: same
} }
stages { stages {
stage('Environment') { stage('Environment') {
@ -68,34 +66,46 @@ pipeline {
} }
} }
stage('Build') { stage('Build') {
steps { parallel {
sh './scripts/ci/build-frontend' stage('Project') {
sh './scripts/ci/test-backend' steps {
// Temporarily disable building backend binaries sh './scripts/ci/build-frontend'
// sh './scripts/ci/build-backend' sh './scripts/ci/test-backend'
// Build the docker image used for testing below // Temporarily disable building backend binaries
sh '''docker build --pull --no-cache \\ // sh './scripts/ci/build-backend'
-t "${IMAGE}:${BRANCH_LOWER}-ci-${BUILD_NUMBER}" \\ // Build the docker image used for testing below
-f docker/Dockerfile \\ sh '''docker build --pull --no-cache \\
--build-arg BUILD_COMMIT="${BUILD_COMMIT}" \\ -t "${IMAGE}:${BRANCH_LOWER}-ci-${BUILD_NUMBER}" \\
--build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \\ -f docker/Dockerfile \\
--build-arg BUILD_VERSION="${BUILD_VERSION}" \\ --build-arg BUILD_COMMIT="${BUILD_COMMIT}" \\
. --build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \\
''' --build-arg BUILD_VERSION="${BUILD_VERSION}" \\
} .
post { '''
success { }
junit 'test/results/junit/*' post {
// archiveArtifacts allowEmptyArchive: false, artifacts: 'bin/*' success {
publishHTML([ junit 'test/results/junit/*'
allowMissing: false, // archiveArtifacts allowEmptyArchive: false, artifacts: 'bin/*'
alwaysLinkToLastBuild: false, publishHTML([
keepAll: false, allowMissing: false,
reportDir: 'test/results/html-reports', alwaysLinkToLastBuild: false,
reportFiles: 'backend-coverage.html', keepAll: false,
reportName: 'HTML Reports', reportDir: 'test/results/html-reports',
useWrapperFileDirectly: true reportFiles: 'backend-coverage.html',
]) reportName: 'HTML Reports',
useWrapperFileDirectly: true
])
}
}
}
stage('Docs') {
steps {
dir(path: 'docs') {
sh 'yarn install'
sh 'yarn build'
}
}
} }
} }
} }
@ -185,27 +195,6 @@ pipeline {
} }
} }
} }
stage('Docs') {
when {
not {
equals expected: 'UNSTABLE', actual: currentBuild.result
}
}
steps {
dir(path: 'docs') {
sh 'yarn install'
sh 'yarn build'
}
// API Docs:
sh 'mkdir -p "docs/.vuepress/dist/api"'
sh 'mv docs/api-schema.json docs/.vuepress/dist/api/'
dir(path: 'docs/.vuepress/dist') {
sh 'tar -czf ../../docs.tgz *'
}
}
}
stage('MultiArch Build') { stage('MultiArch Build') {
when { when {
not { not {
@ -220,31 +209,35 @@ pipeline {
} }
} }
} }
stage('Docs Deploy') { stage('Docs / Comment') {
when { parallel {
allOf { stage('Docs Job') {
branch 'v3' // TODO: change to master when ready when {
not { allOf {
equals expected: 'UNSTABLE', actual: currentBuild.result branch pattern: "^(develop|master|v3)\$", comparator: "REGEXP"
not {
equals expected: 'UNSTABLE', actual: currentBuild.result
}
}
}
steps {
build wait: false, job: 'nginx-proxy-manager-docs', parameters: [string(name: 'docs_branch', value: "$BRANCH_NAME")]
} }
} }
} stage('PR Comment') {
steps { when {
npmDocsRelease("$DOCS_BUCKET", "$DOCS_CDN") allOf {
} changeRequest()
} not {
stage('PR Comment') { equals expected: 'UNSTABLE', actual: currentBuild.result
when { }
allOf { }
changeRequest() }
not { steps {
equals expected: 'UNSTABLE', actual: currentBuild.result 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/${DOCKER_ORG}/${IMAGE}) as `${DOCKER_ORG}/${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)
} }
} }
} }