Jenkins: skip the duplicate CI build on main, clean up stage images, plain build log.
docker-registry-aio/pipeline/head This commit looks good
ysj7705/docker-registry-aio/pipeline/head This commit looks good

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ysj7705andClaude Opus 5.5 committed 2026-10-08 10:44:18 +09:00
1 parent 421e8062e6
commit c1069820db
3 files changed
+18 -19

No files matched your search

Vendored
+15 -17
View File
@@ -1,3 +1,8 @@
def isMain() {
def branch = env.BRANCH_NAME ?: env.GIT_BRANCH ?: ''
return !env.CHANGE_ID && branch in ['main', 'origin/main', 'refs/heads/main']
}
pipeline {
agent any
@@ -25,31 +30,24 @@ pipeline {
}
stage('Build') {
// main is built by Deploy itself; building here too would double the time.
when { not { expression { isMain() } } }
steps {
// Same Dockerfile the NAS builds; the agent shares the host daemon,
// so this also warms the build cache for the Deploy stage.
// Image check only. The agent uses the legacy builder, which leaves untagged images
// for the deps/build stages, so tag every stage and remove them all afterwards.
sh '''
set -eu
tag="registry-aio-app-ci:$(printf '%s' "$BUILD_TAG" | tr -c 'A-Za-z0-9_.-' '-' | cut -c1-128)"
trap 'docker image rm "$tag" >/dev/null 2>&1 || true' EXIT
docker build -t "$tag" app
tag="registry-aio-app-ci:$(printf '%s' "$BUILD_TAG" | tr -c 'A-Za-z0-9_.-' '-' | cut -c1-120)"
trap 'docker image rm "$tag-deps" "$tag-build" "$tag" >/dev/null 2>&1 || true' EXIT
docker build -q --target deps -t "$tag-deps" app
docker build -q --target build -t "$tag-build" app
docker build -q -t "$tag" app
'''
}
}
stage('Deploy') {
when {
allOf {
not { changeRequest() }
anyOf {
branch 'main'
expression {
def branch = env.GIT_BRANCH ?: env.BRANCH_NAME ?: ''
branch == 'main' || branch == 'origin/main' || branch == 'refs/heads/main'
}
}
}
}
when { expression { isMain() } }
steps {
// Keep the existing flow: the NAS checkout is the deployment.
// Fast-forward it to the built commit, then rebuild app and `compose up -d` there.