This commit is contained in:
Jamie Curnow 2023-03-08 12:30:46 +10:00
parent fc55ad9818
commit b8e7b59766
No known key found for this signature in database
GPG key ID: FFBB624C43388E9E
3 changed files with 33 additions and 40 deletions

48
Jenkinsfile vendored
View file

@ -60,50 +60,19 @@ pipeline {
} }
} }
} }
stage('Frontend') { stage('Build and Test') {
steps { steps {
sh './scripts/frontend-build'
}
}
stage('Backend') {
steps {
sh 'env'
echo 'Checking Syntax ...'
sh 'docker pull nginxproxymanager/nginx-full:certbot-node'
// See: https://github.com/yarnpkg/yarn/issues/3254
script { script {
def shStatusCode = sh(label: 'Checking Syntax', returnStatus: true, script: ''' def shStatusCode = 0
set +x // Frontend
docker run --rm \\ shStatusCode = sh(label: 'Checking and Building', returnStatus: true, script: './scripts/ci/frontend-build > ${WORKSPACE}/tmp-sh-frontend-build 2>&1')
-v "$(pwd)/backend:/app" \\ shOutput = readFile "${env.WORKSPACE}/tmp-sh-frontend-build"
-v "$(pwd)/global:/app/global" \\
-w /app \\
nginxproxymanager/nginx-full:certbot-node \\
sh -c "yarn install && yarn eslint . && rm -rf node_modules" \\
> ${WORKSPACE}/tmp-sh-output 2>&1
''')
shOutput = readFile "${env.WORKSPACE}/tmp-sh-output"
if (shStatusCode != 0) { if (shStatusCode != 0) {
error "Error: ${shOutput}" error "Error: ${shOutput}"
} }
} // Backend
shStatusCode = sh(label: 'Checking and Building', returnStatus: true, script: './scripts/ci/test-and-build > ${WORKSPACE}/tmp-sh-test-and-build 2>&1')
echo 'Docker Build ...' shOutput = readFile "${env.WORKSPACE}/tmp-sh-test-and-build"
script {
def shStatusCode = sh(label: 'Building Docker', returnStatus: true, script: '''
set +x
docker build --pull --no-cache --squash --compress \\
-t "${IMAGE}:ci-${BUILD_NUMBER}" \\
-f docker/Dockerfile \\
--build-arg TARGETPLATFORM=linux/amd64 \\
--build-arg BUILDPLATFORM=linux/amd64 \\
--build-arg BUILD_VERSION="${BUILD_VERSION}" \\
--build-arg BUILD_COMMIT="${BUILD_COMMIT}" \\
--build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \\
. \\
> ${WORKSPACE}/tmp-sh-output 2>&1
''')
shOutput = readFile "${env.WORKSPACE}/tmp-sh-output"
if (shStatusCode != 0) { if (shStatusCode != 0) {
error "Error: ${shOutput}" error "Error: ${shOutput}"
} }
@ -111,7 +80,6 @@ pipeline {
} }
post { post {
failure { failure {
echo "SHOUTPUT: -->${shOutput}<--"
npmGithubPrComment("CI Error:\n\n```\n${shOutput}\n```", true) npmGithubPrComment("CI Error:\n\n```\n${shOutput}\n```", true)
} }
} }

25
scripts/ci/test-and-build Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash
set +x
DOCKER_IMAGE=nginxproxymanager/nginx-full:certbot-node
docker pull "${DOCKER_IMAGE}"
# Test
docker run --rm \
-v "$(pwd)/backend:/app" \
-v "$(pwd)/global:/app/global" \
-w /app \
"${DOCKER_IMAGE}" \
sh -c 'yarn install && yarn eslint . && rm -rf node_modules'
# Build
docker build --pull --no-cache --squash --compress \
-t "${IMAGE}:ci-${BUILD_NUMBER}" \
-f docker/Dockerfile \
--build-arg TARGETPLATFORM=linux/amd64 \
--build-arg BUILDPLATFORM=linux/amd64 \
--build-arg BUILD_VERSION="${BUILD_VERSION}" \
--build-arg BUILD_COMMIT="${BUILD_COMMIT}" \
--build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \
.