From 2deea2d072cf989856134d87625fdbc717de0790 Mon Sep 17 00:00:00 2001 From: lingniu Date: Wed, 1 Jul 2026 12:27:21 +0800 Subject: [PATCH] ci: reuse active app list in woodpecker --- .../ingest/historyapp/WoodpeckerPipelineTest.java | 15 ++++++++++++++- woodpecker.yml | 5 +++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/apps/vehicle-history-app/src/test/java/com/lingniu/ingest/historyapp/WoodpeckerPipelineTest.java b/modules/apps/vehicle-history-app/src/test/java/com/lingniu/ingest/historyapp/WoodpeckerPipelineTest.java index b484d0e3..fb40333c 100644 --- a/modules/apps/vehicle-history-app/src/test/java/com/lingniu/ingest/historyapp/WoodpeckerPipelineTest.java +++ b/modules/apps/vehicle-history-app/src/test/java/com/lingniu/ingest/historyapp/WoodpeckerPipelineTest.java @@ -15,7 +15,8 @@ class WoodpeckerPipelineTest { String pipeline = Files.readString(repositoryRoot().resolve("woodpecker.yml")); assertThat(pipeline) - .contains("ACTIVE_APPS=\"gb32960-ingest-app jt808-ingest-app yutong-mqtt-app vehicle-history-app vehicle-analytics-app\"") + .contains("ACTIVE_APPS: &active_apps \"gb32960-ingest-app jt808-ingest-app yutong-mqtt-app vehicle-history-app vehicle-analytics-app\"") + .contains("ACTIVE_APPS: *active_apps") .contains("- name: docker-build-apps") .doesNotContain("xinda-push-app") .doesNotContain("KAFKA_TOPIC_XINDA_PUSH"); @@ -23,6 +24,18 @@ class WoodpeckerPipelineTest { assertThat(countOccurrences(pipeline, "- name: docker-build-")).isEqualTo(1); } + @Test + void activeAppListIsDefinedOnceAndReusedAcrossPipelineSteps() throws IOException { + String pipeline = Files.readString(repositoryRoot().resolve("woodpecker.yml")); + String activeApps = "gb32960-ingest-app jt808-ingest-app yutong-mqtt-app vehicle-history-app vehicle-analytics-app"; + + assertThat(countOccurrences(pipeline, activeApps)).isEqualTo(1); + assertThat(pipeline) + .contains("ACTIVE_APPS: &active_apps \"" + activeApps + "\"") + .contains("ACTIVE_APPS: *active_apps") + .doesNotContain("ACTIVE_APPS=\"" + activeApps + "\""); + } + @Test void dockerImageExposesOnlyCurrentProductionPorts() throws IOException { String dockerfile = Files.readString(repositoryRoot().resolve("Dockerfile")); diff --git a/woodpecker.yml b/woodpecker.yml index 8281b34b..bd7b3ecf 100644 --- a/woodpecker.yml +++ b/woodpecker.yml @@ -10,10 +10,11 @@ steps: - master - develop - main + environment: + ACTIVE_APPS: &active_apps "gb32960-ingest-app jt808-ingest-app yutong-mqtt-app vehicle-history-app vehicle-analytics-app" commands: | cd $CI_WORKSPACE - ACTIVE_APPS="gb32960-ingest-app jt808-ingest-app yutong-mqtt-app vehicle-history-app vehicle-analytics-app" ACTIVE_MODULES="" for APP_NAME in $ACTIVE_APPS; do if [ -z "$ACTIVE_MODULES" ]; then @@ -48,13 +49,13 @@ steps: volumes: - /var/run/docker.sock:/var/run/docker.sock environment: + ACTIVE_APPS: *active_apps ALIYUN_ACR_USERNAME: from_secret: aliyun_acr_username ALIYUN_ACR_PASSWORD: from_secret: aliyun_acr_password commands: | cd $CI_WORKSPACE - ACTIVE_APPS="gb32960-ingest-app jt808-ingest-app yutong-mqtt-app vehicle-history-app vehicle-analytics-app" APP_VERSION=$(cat $CI_WORKSPACE/project_version.txt) REGISTRY=crpi-85r4m0ackrm3qpje.cn-shanghai.personal.cr.aliyuncs.com NAMESPACE=oneos