Skip to content

Commit 54864f4

Browse files
authored
Merge branch 'NginxProxyManager:develop' into develop
2 parents 6c5f198 + 82d9452 commit 54864f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2032
-2698
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.9.18
1+
2.9.21

Jenkinsfile

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import groovy.transform.Field
2+
3+
@Field
4+
def shOutput = ""
5+
def buildxPushTags = ""
6+
17
pipeline {
28
agent {
39
label 'docker-multiarch'
@@ -16,6 +22,8 @@ pipeline {
1622
COMPOSE_FILE = 'docker/docker-compose.ci.yml'
1723
COMPOSE_INTERACTIVE_NO_CLI = 1
1824
BUILDX_NAME = "${COMPOSE_PROJECT_NAME}"
25+
DOCS_BUCKET = 'jc21-npm-site'
26+
DOCS_CDN = 'EN1G6DEWZUTDT'
1927
}
2028
stages {
2129
stage('Environment') {
@@ -26,7 +34,7 @@ pipeline {
2634
}
2735
steps {
2836
script {
29-
env.BUILDX_PUSH_TAGS = "-t docker.io/jc21/${IMAGE}:${BUILD_VERSION} -t docker.io/jc21/${IMAGE}:${MAJOR_VERSION} -t docker.io/jc21/${IMAGE}:latest"
37+
buildxPushTags = "-t docker.io/jc21/${IMAGE}:${BUILD_VERSION} -t docker.io/jc21/${IMAGE}:${MAJOR_VERSION} -t docker.io/jc21/${IMAGE}:latest"
3038
}
3139
}
3240
}
@@ -39,7 +47,7 @@ pipeline {
3947
steps {
4048
script {
4149
// Defaults to the Branch name, which is applies to all branches AND pr's
42-
env.BUILDX_PUSH_TAGS = "-t docker.io/jc21/${IMAGE}:github-${BRANCH_LOWER}"
50+
buildxPushTags = "-t docker.io/jc21/${IMAGE}:github-${BRANCH_LOWER}"
4351
}
4452
}
4553
}
@@ -54,35 +62,28 @@ pipeline {
5462
}
5563
}
5664
}
57-
stage('Frontend') {
65+
stage('Build and Test') {
5866
steps {
59-
sh './scripts/frontend-build'
67+
script {
68+
// Frontend and Backend
69+
def shStatusCode = sh(label: 'Checking and Building', returnStatus: true, script: '''
70+
set -e
71+
./scripts/ci/frontend-build > ${WORKSPACE}/tmp-sh-build 2>&1
72+
./scripts/ci/test-and-build > ${WORKSPACE}/tmp-sh-build 2>&1
73+
''')
74+
shOutput = readFile "${env.WORKSPACE}/tmp-sh-build"
75+
if (shStatusCode != 0) {
76+
error "${shOutput}"
77+
}
78+
}
6079
}
61-
}
62-
stage('Backend') {
63-
steps {
64-
echo 'Checking Syntax ...'
65-
sh 'docker pull nginxproxymanager/nginx-full:certbot-node'
66-
// See: https://github.com/yarnpkg/yarn/issues/3254
67-
sh '''docker run --rm \\
68-
-v "$(pwd)/backend:/app" \\
69-
-v "$(pwd)/global:/app/global" \\
70-
-w /app \\
71-
nginxproxymanager/nginx-full:certbot-node \\
72-
sh -c "yarn install && yarn eslint . && rm -rf node_modules"
73-
'''
74-
75-
echo 'Docker Build ...'
76-
sh '''docker build --pull --no-cache --squash --compress \\
77-
-t "${IMAGE}:ci-${BUILD_NUMBER}" \\
78-
-f docker/Dockerfile \\
79-
--build-arg TARGETPLATFORM=linux/amd64 \\
80-
--build-arg BUILDPLATFORM=linux/amd64 \\
81-
--build-arg BUILD_VERSION="${BUILD_VERSION}" \\
82-
--build-arg BUILD_COMMIT="${BUILD_COMMIT}" \\
83-
--build-arg BUILD_DATE="$(date '+%Y-%m-%d %T %Z')" \\
84-
.
85-
'''
80+
post {
81+
always {
82+
sh 'rm -f ${WORKSPACE}/tmp-sh-build'
83+
}
84+
failure {
85+
npmGithubPrComment("CI Error:\n\n```\n${shOutput}\n```", true)
86+
}
8687
}
8788
}
8889
stage('Integration Tests Sqlite') {
@@ -164,10 +165,8 @@ pipeline {
164165
}
165166
steps {
166167
withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
167-
// Docker Login
168-
sh "docker login -u '${duser}' -p '${dpass}'"
169-
// Buildx with push from cache
170-
sh "./scripts/buildx --push ${BUILDX_PUSH_TAGS}"
168+
sh 'docker login -u "${duser}" -p "${dpass}"'
169+
sh "./scripts/buildx --push ${buildxPushTags}"
171170
}
172171
}
173172
}
@@ -181,26 +180,7 @@ pipeline {
181180
}
182181
}
183182
steps {
184-
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'npm-s3-docs', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
185-
sh """docker run --rm \\
186-
--name \${COMPOSE_PROJECT_NAME}-docs-upload \\
187-
-e S3_BUCKET=jc21-npm-site \\
188-
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \\
189-
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \\
190-
-v \$(pwd):/app \\
191-
-w /app \\
192-
jc21/ci-tools \\
193-
scripts/docs-upload /app/docs/.vuepress/dist/
194-
"""
195-
196-
sh """docker run --rm \\
197-
--name \${COMPOSE_PROJECT_NAME}-docs-invalidate \\
198-
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \\
199-
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \\
200-
jc21/ci-tools \\
201-
aws cloudfront create-invalidation --distribution-id EN1G6DEWZUTDT --paths '/*'
202-
"""
203-
}
183+
npmDocsRelease("$DOCS_BUCKET", "$DOCS_CDN")
204184
}
205185
}
206186
stage('PR Comment') {
@@ -214,7 +194,7 @@ pipeline {
214194
}
215195
steps {
216196
script {
217-
def comment = pullRequest.comment("This is an automated message from CI:\n\nDocker 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.")
197+
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)
218198
}
219199
}
220200
}

0 commit comments

Comments
 (0)