Files
devops-lib-gcp/docs/wiki/pages/05-ENVIRONMENT-MAPPING.md
T
2026-08-26 02:02:24 +05:30

3.5 KiB

Generated 2026-05-12 at base-sha 28f54cf7bef9. Type: top-level. 0 sources.

Environment Mapping

cicd_environment is the single string that controls which registry, vault, ArgoCD cluster, and GCS bucket the pipeline uses. It is derived from the branch name (for push builds) or the PR target branch (for PR builds).

TL;DR

  • Push to main/master/gcp-mainprd.
  • Push to developstg.
  • PR targeting mainint (pre-prod).
  • PR targeting developftr (feature).
  • Any other branch → ftr (fallback).
  • Hotfix branches skip tests and Sonar but still map to prd.
  • env.CHANGE_ID being set signals a PR build and flips the mapping table.

Mental model

constructParam.run() switches on env.CHANGE_ID to decide which environment_map to use. Without CHANGE_ID (push build), branches map to their canonical environments. With CHANGE_ID (PR build), the same branch names map to the pre-prod equivalents: main→int, develop→ftr. This double-mapping is why develop can be either stg (push) or ftr (PR).

Structure / data flow

env.CHANGE_ID not set (push build):
  environment_map = {
    master/main/gcp-main/farmiso-main/gcp-master → prd
    develop/gcp-dev                               → stg
  }
  branch not in map → ftr (default)

env.CHANGE_ID set (PR build):
  branch_name = env.CHANGE_TARGET
  environment_map = {
    master/main/gcp-main/farmiso-main/gcp-master → int
    develop/gcp-dev                               → ftr
  }

env.cicd_environment = environment_map[branch_name]

Key code locations

Symbol File What it does
run src/com/meesho/utilities/constructParam.groovy:run Sets env.cicd_environment + all env vars
run src/com/meesho/stages/deployArgoCD.groovy:run Has its own branch_param_map for helm/argo branch naming
run src/com/meesho/stages/hotFix.groovy:run Detects hotfix/* branch and sets env.hot_fix=true

Sharp edges

  • Two separate maps exist: constructParam has one map for cicd_environment; deployArgoCD has a different branch_param_map for the Helm/Argo Git branch names (main, develop, feature, pre-prod). These are not the same and must not be conflated.
  • gcp-dev maps to stg: services on the gcp-dev branch deploy to staging, not a separate dev environment.
  • Toolchain override: if env.INFRA_ENV == 'toolchain' and the service is Node, branch_name is forced to develop so the image goes to stg toolchain registry regardless of actual branch.
  • farmiso-main is treated as an alias for main — it maps to prd on both push and PR builds to main.
  • Use env.CHANGE_ID to detect PR context — not env.BRANCH_NAME =~ /PR-/: the BRANCH_NAME =~ /PR-/ pattern breaks on non-GitHub SCMs and re-triggered builds. env.CHANGE_ID is the canonical PR-build detector set by the GitHub Branch Source plugin and is used throughout constructParam.groovy:run (src/com/meesho/utilities/constructParam.groovy:run).

Notes


← Previous · Index · Next →