]> source.dussan.org Git - sonarqube.git/commitdiff
[NO-JIRA] Declare branch names and patterns as constant
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Mon, 22 Aug 2022 10:37:22 +0000 (12:37 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 23 Aug 2022 20:03:04 +0000 (20:03 +0000)
.cirrus.yml

index 1fedb555fff571a2476b7054d08ba3aaa678808a..9917ddc03ae3868dcc092ac1b9df50ed1cf182cd 100644 (file)
@@ -26,24 +26,28 @@ env:
   # Depth of 1 is not enough because it would fail the build in case of consecutive pushes
   # (example of error: "Hard resetting to c968ecaf7a1942dacecd78480b3751ac74d53c33...Failed to force reset to c968ecaf7a1942dacecd78480b3751ac74d53c33: object not found!")
   CIRRUS_CLONE_DEPTH: 50
+  BRANCH_MAIN: 'master'
+  BRANCH_NIGHTLY: 'branch-nightly-build'
+  BRANCH_PATTERN_MAINTENANCE: 'branch-.*'
+  BRANCH_PATTERN_PUBLIC: 'public_.*'
 
-auto_cancellation: $CIRRUS_BRANCH != 'master' && $CIRRUS_BRANCH !=~ 'branch.*'
+auto_cancellation: $CIRRUS_BRANCH != $BRANCH_MAIN && $CIRRUS_BRANCH !=~ $BRANCH_PATTERN_MAINTENANCE
 
 skip_public_branches_template: &SKIP_PUBLIC_BRANCHES_TEMPLATE
-  skip: $CIRRUS_BRANCH =~ 'public_.*'
+  skip: $CIRRUS_BRANCH =~ $BRANCH_PATTERN_PUBLIC
 
 build_dependant_task_template: &BUILD_DEPENDANT_TASK_TEMPLATE
   depends_on: build
 
 nightly_task_template: &NIGHTLY_TASK_TEMPLATE
-  only_if: $CIRRUS_BRANCH == "branch-nightly-build"
+  only_if: $CIRRUS_BRANCH == $BRANCH_NIGHTLY
 
 except_nightly_task_template: &EXCEPT_ON_NIGHTLY_TASK_TEMPLATE
-  only_if: $CIRRUS_BRANCH != "branch-nightly-build"
+  only_if: $CIRRUS_BRANCH != $BRANCH_NIGHTLY
 
 database_related_nightly_task_template: &DATABASE_RELATED_NIGHTLY_TASK_TEMPLATE
   only_if: >-
-    $CIRRUS_BRANCH == "branch-nightly-build" ||
+    $CIRRUS_BRANCH == $BRANCH_NIGHTLY ||
     changesInclude('server/sonar-db-dao/**/*Mapper.xml', 'server/sonar-db-migration/**/DbVersion*.java', 'server/sonar-db-dao/**/*Dao.java')
 
 docker_build_container_template: &GKE_CONTAINER_TEMPLATE
@@ -464,7 +468,7 @@ promote_task:
 package_docker_task:
   <<: *SKIP_PUBLIC_BRANCHES_TEMPLATE
   depends_on: promote
-  only_if: $CIRRUS_BRANCH == 'master'
+  only_if: $CIRRUS_BRANCH == $BRANCH_MAIN
   gce_instance:
     image_project: sonarqube-team
     image_family: docker-builder
@@ -593,8 +597,8 @@ ws_scan_task:
   <<: *SKIP_PUBLIC_BRANCHES_TEMPLATE
   <<: *BUILD_DEPENDANT_TASK_TEMPLATE
   only_if: >-
-    $CIRRUS_BRANCH == 'master' ||
-    ($CIRRUS_BRANCH =~ 'branch.*' && $CIRRUS_BRANCH != 'branch-nightly-build')
+    $CIRRUS_BRANCH == $BRANCH_MAIN ||
+    ($CIRRUS_BRANCH =~ $BRANCH_PATTERN_MAINTENANCE && $CIRRUS_BRANCH != $BRANCH_NIGHTLY)
   <<: *YARN_CACHE_TEMPLATE
   <<: *GRADLE_CACHE_TEMPLATE
   timeout_in: 30m