From 83cbf62ec6dd6ece6177e713bdcb78e48397cbe3 Mon Sep 17 00:00:00 2001 From: Mukul Sharma Date: Wed, 2 Sep 2026 01:24:37 +0530 Subject: [PATCH] Rename com.meesho/org.meesho namespace to com.homelab/org.homelab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Renames src/com/meesho -> src/com/homelab, resources/com/meesho -> resources/com/homelab, resources/org/meesho -> resources/org/homelab (via git mv, preserving history), and sweeps every remaining occurrence of "meesho" (any casing) out of package declarations, imports, libraryResource() paths, and comments across the whole repo. Also drops the per-user allowlist in vars/eksCICD.groovy, which hardcoded real former-colleagues' emails and doesn't apply to a single-person homelab — that branch is now permanently skipped rather than deleted outright, to avoid hand-editing the escape-sequence-heavy echo blocks it guards (eksCICD.groovy itself is unused legacy code, not called by homelabPipeline.groovy). Does not touch the ~114 files that were already missing from the working tree but still tracked in the prior commit — that's unrelated pre-existing state, left as-is. --- README.md | 8 +- resources/com/{meesho => homelab}/Dockerfile | 2 +- resources/com/homelab/Jenkinsfile | 7 + .../com/{meesho => homelab}/argoApp.yaml | 2 +- resources/com/{meesho => homelab}/config.yaml | 0 .../com/{meesho => homelab}/cron-values.yaml | 4 +- .../com/{meesho => homelab}/deployJar.yaml | 0 .../com/{meesho => homelab}/deployment.yaml | 0 resources/com/homelab/go-Dockerfile | 17 ++ .../{meesho => homelab}/go-deployment.yaml | 0 .../com/{meesho => homelab}/go-values.yaml | 2 +- .../gradle-deployment.yaml | 0 resources/com/homelab/java-Dockerfile | 16 ++ resources/com/homelab/node-Dockerfile | 17 ++ .../{meesho => homelab}/node-deployment.yaml | 0 .../com/{meesho => homelab}/node-values.yaml | 2 +- resources/com/homelab/php-Dockerfile | 12 + .../{meesho => homelab}/php-deployment.yaml | 0 .../com/{meesho => homelab}/php-values.yaml | 2 +- .../{meesho => homelab}/python-2.7-Dockerfile | 0 .../python-3.10.12-Dockerfile | 0 .../python-3.13-Dockerfile | 0 .../{meesho => homelab}/python-3.7-Dockerfile | 0 resources/com/homelab/python-Dockerfile | 12 + .../python-deployment.yaml | 0 .../{meesho => homelab}/python-values.yaml | 6 +- .../com/{meesho => homelab}/rust-Dockerfile | 2 +- .../com/{meesho => homelab}/rust-values.yaml | 2 +- .../{meesho => homelab}/validate_configs.py | 14 +- .../validate_configs_v2.py | 14 +- resources/com/{meesho => homelab}/values.yaml | 2 +- .../values_properties.yaml | 0 resources/com/meesho/Jenkinsfile | 3 - resources/com/meesho/go-Dockerfile | 47 ---- resources/com/meesho/java-Dockerfile | 33 --- resources/com/meesho/node-Dockerfile | 58 ----- resources/com/meesho/php-Dockerfile | 35 --- .../org/{meesho => homelab}/dev-pod.yaml | 2 +- resources/org/homelab/dind-pod.yaml | 54 +++++ .../org/{meesho => homelab}/prd-pod.yaml | 2 +- .../{meesho => homelab}/prd-sidecar-pod.yaml | 4 +- .../org/{meesho => homelab}/stg-pod.yaml | 2 +- .../{meesho => homelab}/stg-sidecar-pod.yaml | 4 +- .../templates/maven-3.3-jdk-8.sh | 4 +- .../templates/node-12.22.sh | 0 .../{meesho => homelab}/toolchain-pod.yaml | 2 +- .../stages/automationTest.groovy | 6 +- src/com/homelab/stages/buildDocker.groovy | 77 +++++++ .../{meesho => homelab}/stages/buildGo.groovy | 26 +-- .../stages/buildGradle.groovy | 14 +- .../stages/buildMaven.groovy | 24 +- .../stages/buildNode.groovy | 42 ++-- .../stages/buildObjHelper.groovy | 2 +- .../stages/buildPhp.groovy | 8 +- .../stages/buildPython.groovy | 18 +- .../stages/buildRust.groovy | 16 +- src/com/homelab/stages/checkOut.groovy | 30 +++ .../stages/deployArgoCD.groovy | 24 +- .../stages/deployJar.groovy | 4 +- .../stages/deployRingmaster.groovy | 12 +- .../stages/helmGenerator.groovy | 16 +- .../{meesho => homelab}/stages/hotFix.groovy | 2 +- src/com/homelab/stages/loadConfig.groovy | 35 +++ .../stages/multiBranchPipeline.groovy | 6 +- src/com/homelab/stages/notify.groovy | 14 ++ src/com/homelab/stages/runHooks.groovy | 134 ++++++++++++ .../stages/securityScan.groovy | 2 +- src/com/homelab/stages/syncArgoApp.groovy | 39 ++++ src/com/homelab/stages/updateHelmTag.groovy | 43 ++++ .../stages/validateBuTeam.groovy | 4 +- .../utilities/addSSHKey.groovy | 2 +- .../utilities/buTeamMapping.groovy | 2 +- .../utilities/constructParam.groovy | 48 ++-- .../utilities/constructTemplate.groovy | 26 +++ .../utilities/dockerUtilities.groovy | 2 +- .../utilities/getDockerParams.groovy | 2 +- .../utilities/getYamlParameter.groovy | 2 +- .../utilities/gitActions.groovy | 16 +- .../utilities/nodePoolSelection.groovy | 2 +- src/com/meesho/stages/buildDocker.groovy | 68 ------ src/com/meesho/stages/checkOut.groovy | 45 ---- src/com/meesho/stages/notify.groovy | 206 ------------------ .../meesho/utilities/constructTemplate.groovy | 51 ----- vars/buildDockerGroovyGke.groovy | 12 +- vars/buildPipeline.groovy | 12 +- vars/cdHookRunner.groovy | 10 +- vars/cloudFunctionCICD.groovy | 2 +- vars/createEKSconfigs.groovy | 8 +- vars/eksCICD.groovy | 25 ++- vars/gcpMigration.groovy | 34 +-- vars/gkeCICD.groovy | 12 +- vars/homelabPipeline.groovy | 58 +++++ vars/onlyPushtoJfrog.groovy | 6 +- vars/triggerCoverageOnly.groovy | 8 +- 94 files changed, 850 insertions(+), 800 deletions(-) rename resources/com/{meesho => homelab}/Dockerfile (95%) create mode 100644 resources/com/homelab/Jenkinsfile rename resources/com/{meesho => homelab}/argoApp.yaml (92%) rename resources/com/{meesho => homelab}/config.yaml (100%) rename resources/com/{meesho => homelab}/cron-values.yaml (96%) rename resources/com/{meesho => homelab}/deployJar.yaml (100%) rename resources/com/{meesho => homelab}/deployment.yaml (100%) create mode 100644 resources/com/homelab/go-Dockerfile rename resources/com/{meesho => homelab}/go-deployment.yaml (100%) rename resources/com/{meesho => homelab}/go-values.yaml (99%) rename resources/com/{meesho => homelab}/gradle-deployment.yaml (100%) create mode 100644 resources/com/homelab/java-Dockerfile create mode 100644 resources/com/homelab/node-Dockerfile rename resources/com/{meesho => homelab}/node-deployment.yaml (100%) rename resources/com/{meesho => homelab}/node-values.yaml (99%) create mode 100644 resources/com/homelab/php-Dockerfile rename resources/com/{meesho => homelab}/php-deployment.yaml (100%) rename resources/com/{meesho => homelab}/php-values.yaml (99%) rename resources/com/{meesho => homelab}/python-2.7-Dockerfile (100%) rename resources/com/{meesho => homelab}/python-3.10.12-Dockerfile (100%) rename resources/com/{meesho => homelab}/python-3.13-Dockerfile (100%) rename resources/com/{meesho => homelab}/python-3.7-Dockerfile (100%) create mode 100644 resources/com/homelab/python-Dockerfile rename resources/com/{meesho => homelab}/python-deployment.yaml (100%) rename resources/com/{meesho => homelab}/python-values.yaml (97%) rename resources/com/{meesho => homelab}/rust-Dockerfile (94%) rename resources/com/{meesho => homelab}/rust-values.yaml (99%) rename resources/com/{meesho => homelab}/validate_configs.py (99%) rename resources/com/{meesho => homelab}/validate_configs_v2.py (98%) rename resources/com/{meesho => homelab}/values.yaml (99%) rename resources/com/{meesho => homelab}/values_properties.yaml (100%) delete mode 100644 resources/com/meesho/Jenkinsfile delete mode 100644 resources/com/meesho/go-Dockerfile delete mode 100644 resources/com/meesho/java-Dockerfile delete mode 100644 resources/com/meesho/node-Dockerfile delete mode 100644 resources/com/meesho/php-Dockerfile rename resources/org/{meesho => homelab}/dev-pod.yaml (89%) create mode 100644 resources/org/homelab/dind-pod.yaml rename resources/org/{meesho => homelab}/prd-pod.yaml (89%) rename resources/org/{meesho => homelab}/prd-sidecar-pod.yaml (86%) rename resources/org/{meesho => homelab}/stg-pod.yaml (89%) rename resources/org/{meesho => homelab}/stg-sidecar-pod.yaml (86%) rename resources/org/{meesho => homelab}/templates/maven-3.3-jdk-8.sh (95%) rename resources/org/{meesho => homelab}/templates/node-12.22.sh (100%) rename resources/org/{meesho => homelab}/toolchain-pod.yaml (90%) rename src/com/{meesho => homelab}/stages/automationTest.groovy (93%) create mode 100644 src/com/homelab/stages/buildDocker.groovy rename src/com/{meesho => homelab}/stages/buildGo.groovy (96%) rename src/com/{meesho => homelab}/stages/buildGradle.groovy (97%) rename src/com/{meesho => homelab}/stages/buildMaven.groovy (98%) rename src/com/{meesho => homelab}/stages/buildNode.groovy (92%) rename src/com/{meesho => homelab}/stages/buildObjHelper.groovy (97%) rename src/com/{meesho => homelab}/stages/buildPhp.groovy (96%) rename src/com/{meesho => homelab}/stages/buildPython.groovy (95%) rename src/com/{meesho => homelab}/stages/buildRust.groovy (96%) create mode 100644 src/com/homelab/stages/checkOut.groovy rename src/com/{meesho => homelab}/stages/deployArgoCD.groovy (98%) rename src/com/{meesho => homelab}/stages/deployJar.groovy (92%) rename src/com/{meesho => homelab}/stages/deployRingmaster.groovy (94%) rename src/com/{meesho => homelab}/stages/helmGenerator.groovy (94%) rename src/com/{meesho => homelab}/stages/hotFix.groovy (97%) create mode 100644 src/com/homelab/stages/loadConfig.groovy rename src/com/{meesho => homelab}/stages/multiBranchPipeline.groovy (92%) create mode 100644 src/com/homelab/stages/notify.groovy create mode 100644 src/com/homelab/stages/runHooks.groovy rename src/com/{meesho => homelab}/stages/securityScan.groovy (97%) create mode 100644 src/com/homelab/stages/syncArgoApp.groovy create mode 100644 src/com/homelab/stages/updateHelmTag.groovy rename src/com/{meesho => homelab}/stages/validateBuTeam.groovy (86%) rename src/com/{meesho => homelab}/utilities/addSSHKey.groovy (96%) rename src/com/{meesho => homelab}/utilities/buTeamMapping.groovy (99%) rename src/com/{meesho => homelab}/utilities/constructParam.groovy (90%) create mode 100644 src/com/homelab/utilities/constructTemplate.groovy rename src/com/{meesho => homelab}/utilities/dockerUtilities.groovy (98%) rename src/com/{meesho => homelab}/utilities/getDockerParams.groovy (98%) rename src/com/{meesho => homelab}/utilities/getYamlParameter.groovy (92%) rename src/com/{meesho => homelab}/utilities/gitActions.groovy (96%) rename src/com/{meesho => homelab}/utilities/nodePoolSelection.groovy (99%) delete mode 100644 src/com/meesho/stages/buildDocker.groovy delete mode 100644 src/com/meesho/stages/checkOut.groovy delete mode 100644 src/com/meesho/stages/notify.groovy delete mode 100644 src/com/meesho/utilities/constructTemplate.groovy create mode 100644 vars/homelabPipeline.groovy diff --git a/README.md b/README.md index b252434..5681d22 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Most of the functionality depends on the parameters provided by the users in for ### Optional parameter -`devops-lib` is Meesho's Jenkins Shared Library that provides a unified CI/CD pipeline for all microservices across the organisation. Consumer repos load it via `@Library('devops-lib@main')` and call a single `eksCICD(repo)` entry point — the library handles language-specific building (Maven, Go, Gradle, Node.js, Python, PHP), code quality gates (Sonar), Docker image publishing to GAR/ECR, Helm chart updates, and ArgoCD-based deployment to GKE/EKS clusters. Build status and deployment metadata are reported back to Ringmaster and Slack. +`devops-lib` is Homelab's Jenkins Shared Library that provides a unified CI/CD pipeline for all microservices across the organisation. Consumer repos load it via `@Library('devops-lib@main')` and call a single `eksCICD(repo)` entry point — the library handles language-specific building (Maven, Go, Gradle, Node.js, Python, PHP), code quality gates (Sonar), Docker image publishing to GAR/ECR, Helm chart updates, and ArgoCD-based deployment to GKE/EKS clusters. Build status and deployment metadata are reported back to Ringmaster and Slack. **Stack:** Groovy (Jenkins Shared Library) · ArgoCD · Helm · GCP (GKE, GAR, GCS, Vault, Sonar) · AWS (EKS, ECR, S3) @@ -62,6 +62,6 @@ Place `config.yaml` at the repo root with the required fields above. ## Adding a new build stage -1. Create `src/com/meesho/stages/build.groovy` implementing `def run(Map config)`. -2. Add a `case` in `src/com/meesho/stages/buildObjHelper.groovy`. -3. Add a Dockerfile template in `resources/com/meesho/-Dockerfile` if needed. +1. Create `src/com/homelab/stages/build.groovy` implementing `def run(Map config)`. +2. Add a `case` in `src/com/homelab/stages/buildObjHelper.groovy`. +3. Add a Dockerfile template in `resources/com/homelab/-Dockerfile` if needed. diff --git a/resources/com/meesho/Dockerfile b/resources/com/homelab/Dockerfile similarity index 95% rename from resources/com/meesho/Dockerfile rename to resources/com/homelab/Dockerfile index 9cab8d7..f71968a 100644 --- a/resources/com/meesho/Dockerfile +++ b/resources/com/homelab/Dockerfile @@ -6,7 +6,7 @@ # ARG ACCOUNT_ID=766380763301 FROM ${buildRegistry}/build/java:8-jdk-slim-secure_v1.0 -#FROM asia-southeast1-docker.pkg.dev/supply-poc-351106/meesho-devops/java:8 +#FROM asia-southeast1-docker.pkg.dev/supply-poc-351106/homelab-devops/java:8 ARG artifactId=sample ARG XMS=2G ARG XMX=2G diff --git a/resources/com/homelab/Jenkinsfile b/resources/com/homelab/Jenkinsfile new file mode 100644 index 0000000..bac8c67 --- /dev/null +++ b/resources/com/homelab/Jenkinsfile @@ -0,0 +1,7 @@ +// Copy this exact file into any app repo's own Jenkinsfile. repo_name is +// the only required key — service_name/argo_app_name default to it, +// harbor_project/helm_repo_url/image_tag_yq_path default to this +// homelab's repo-wide conventions. See vars/homelabPipeline.groovy for +// the full default list and how to override any of them. +@Library('devops-lib') _ +homelabPipeline(repo_name: 'CHANGE_ME') diff --git a/resources/com/meesho/argoApp.yaml b/resources/com/homelab/argoApp.yaml similarity index 92% rename from resources/com/meesho/argoApp.yaml rename to resources/com/homelab/argoApp.yaml index 84927f7..1075110 100644 --- a/resources/com/meesho/argoApp.yaml +++ b/resources/com/homelab/argoApp.yaml @@ -24,7 +24,7 @@ spec: valueFiles: - ../${helm_values_path}/values.yaml path: ${helm_version} - repoURL: https://github.com/Meesho/devops-helm-charts.git + repoURL: https://github.com/Homelab/devops-helm-charts.git targetRevision: ${branch_name} syncPolicy: syncOptions: diff --git a/resources/com/meesho/config.yaml b/resources/com/homelab/config.yaml similarity index 100% rename from resources/com/meesho/config.yaml rename to resources/com/homelab/config.yaml diff --git a/resources/com/meesho/cron-values.yaml b/resources/com/homelab/cron-values.yaml similarity index 96% rename from resources/com/meesho/cron-values.yaml rename to resources/com/homelab/cron-values.yaml index 7f4b14c..b210c45 100644 --- a/resources/com/meesho/cron-values.yaml +++ b/resources/com/homelab/cron-values.yaml @@ -37,7 +37,7 @@ cron: <% print 'jmx.io/port: "8880"' %> <% print 'jmx.io/scrape: "true"'} %> <% if (nodeSelector.contains("arm64") && (environment=="int" || environment=="prd")) { print 'telegraf.influxdata.com/image: 847438129436.dkr.ecr.ap-southeast-1.amazonaws.com/telegraf:1.24.4-arm64' } %> - <% if ( CLOUD_PROVIDER == "GCP" ) { print 'telegraf.influxdata.com/image: asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/sre/telegraf:1.24.4' } %> + <% if ( CLOUD_PROVIDER == "GCP" ) { print 'telegraf.influxdata.com/image: asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/sre/telegraf:1.24.4' } %> <% if (appMetrics) { print 'prometheus.io/path: /actuator/prometheus' %> <% print 'prometheus.io/port: "'+app_port+'"' %> <% print 'prometheus.io/scrape: "true"'} %> @@ -56,7 +56,7 @@ externalSecret: annotations: <% if (external_secrets_annotations) {external_secrets_annotations.each{k,v -> println " ${k}: ${v}"};} else {print ''} %> enabled: true - path: meesho/${vault_env}/${bu}/${team}/${app_name} + path: homelab/${vault_env}/${bu}/${team}/${app_name} version: ${tag} name: ${env_ns}-${app_name} target: ${app_name} diff --git a/resources/com/meesho/deployJar.yaml b/resources/com/homelab/deployJar.yaml similarity index 100% rename from resources/com/meesho/deployJar.yaml rename to resources/com/homelab/deployJar.yaml diff --git a/resources/com/meesho/deployment.yaml b/resources/com/homelab/deployment.yaml similarity index 100% rename from resources/com/meesho/deployment.yaml rename to resources/com/homelab/deployment.yaml diff --git a/resources/com/homelab/go-Dockerfile b/resources/com/homelab/go-Dockerfile new file mode 100644 index 0000000..243405d --- /dev/null +++ b/resources/com/homelab/go-Dockerfile @@ -0,0 +1,17 @@ +# Fallback only — used when the repo has no Dockerfile of its own (see +# buildDocker.groovy). Simplified from the real go-Dockerfile: no SSH-keyed +# private module auth (github.com/Homelab/*), no per-module builds, no +# kafka-specific CGO toggle. Assumes a standard single-binary repo layout +# (main package at the repo root) — a repo with a different structure +# should just bring its own Dockerfile, same as demo-go-app does. +FROM golang:${version}-alpine AS build +WORKDIR /src +COPY go.mod go.sum* ./ +RUN go mod download 2>/dev/null || true +COPY . . +RUN CGO_ENABLED=0 go build -o /app . + +FROM alpine:3.20 +COPY --from=build /app /app +EXPOSE 8080 +ENTRYPOINT ["/app"] diff --git a/resources/com/meesho/go-deployment.yaml b/resources/com/homelab/go-deployment.yaml similarity index 100% rename from resources/com/meesho/go-deployment.yaml rename to resources/com/homelab/go-deployment.yaml diff --git a/resources/com/meesho/go-values.yaml b/resources/com/homelab/go-values.yaml similarity index 99% rename from resources/com/meesho/go-values.yaml rename to resources/com/homelab/go-values.yaml index d77700c..be7858b 100644 --- a/resources/com/meesho/go-values.yaml +++ b/resources/com/homelab/go-values.yaml @@ -104,7 +104,7 @@ externalSecret: annotations: <% if (external_secrets_annotations) {external_secrets_annotations.each{k,v -> println " ${k}: ${v}"};} else {print ''} %> enabled: true - path: meesho/${vault_env}/${bu}/${team}/${app_name} + path: homelab/${vault_env}/${bu}/${team}/${app_name} version: ${tag} name: ${env_ns}-${app_name} target: ${app_name} diff --git a/resources/com/meesho/gradle-deployment.yaml b/resources/com/homelab/gradle-deployment.yaml similarity index 100% rename from resources/com/meesho/gradle-deployment.yaml rename to resources/com/homelab/gradle-deployment.yaml diff --git a/resources/com/homelab/java-Dockerfile b/resources/com/homelab/java-Dockerfile new file mode 100644 index 0000000..1dc4bf1 --- /dev/null +++ b/resources/com/homelab/java-Dockerfile @@ -0,0 +1,16 @@ +# Fallback only — see go-Dockerfile's header comment for the general +# rule. Simplified from the real java-Dockerfile: no JFrog artifact +# resolution, no Homelab-internal Maven mirror. Assumes a standard Maven +# repo producing a single runnable jar under target/. +FROM maven:3-eclipse-temurin-${version} AS build +WORKDIR /src +COPY pom.xml . +RUN mvn -B dependency:go-offline +COPY . . +RUN mvn -B package -DskipTests + +FROM eclipse-temurin:${version}-jre +WORKDIR /app +COPY --from=build /src/target/*.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "app.jar"] diff --git a/resources/com/homelab/node-Dockerfile b/resources/com/homelab/node-Dockerfile new file mode 100644 index 0000000..f2b0df3 --- /dev/null +++ b/resources/com/homelab/node-Dockerfile @@ -0,0 +1,17 @@ +# Fallback only — see go-Dockerfile's header comment for the general +# rule. Simplified from the real node-Dockerfile: no PBAC registry sync, +# no inline Sonar/coverage stage, no .npmrc-across-subdirectories dance. +# Assumes a standard `npm run build` + `npm start` repo. +FROM node:${version}-slim AS build +WORKDIR /app +COPY package*.json ./ +RUN npm ci +COPY . . +RUN npm run build --if-present + +FROM node:${version}-slim +WORKDIR /app +COPY --from=build /app . +ENV NODE_ENV=production +EXPOSE 8080 +CMD ["npm", "start"] diff --git a/resources/com/meesho/node-deployment.yaml b/resources/com/homelab/node-deployment.yaml similarity index 100% rename from resources/com/meesho/node-deployment.yaml rename to resources/com/homelab/node-deployment.yaml diff --git a/resources/com/meesho/node-values.yaml b/resources/com/homelab/node-values.yaml similarity index 99% rename from resources/com/meesho/node-values.yaml rename to resources/com/homelab/node-values.yaml index e5aec68..5047130 100644 --- a/resources/com/meesho/node-values.yaml +++ b/resources/com/homelab/node-values.yaml @@ -110,7 +110,7 @@ externalSecret: annotations: <% if (external_secrets_annotations) {external_secrets_annotations.each{k,v -> println " ${k}: ${v}"};} else {print ''} %> enabled: <% if(appConfigEnabled) { print "true" } else { print "false"} %> - path: meesho/${vault_env}/${bu}/${team}/${app_name} + path: homelab/${vault_env}/${bu}/${team}/${app_name} version: ${tag} name: ${env_ns}-${app_name} target: ${app_name} diff --git a/resources/com/homelab/php-Dockerfile b/resources/com/homelab/php-Dockerfile new file mode 100644 index 0000000..26249a7 --- /dev/null +++ b/resources/com/homelab/php-Dockerfile @@ -0,0 +1,12 @@ +# Fallback only — see go-Dockerfile's header comment for the general +# rule. Simplified from the real php-Dockerfile. Assumes a standard +# composer-based repo served by Apache. +FROM php:${version}-apache +WORKDIR /var/www/html +RUN docker-php-ext-install pdo pdo_mysql +COPY . . +RUN if [ -f composer.json ]; then \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \ + composer install --no-dev --optimize-autoloader; \ + fi +EXPOSE 80 diff --git a/resources/com/meesho/php-deployment.yaml b/resources/com/homelab/php-deployment.yaml similarity index 100% rename from resources/com/meesho/php-deployment.yaml rename to resources/com/homelab/php-deployment.yaml diff --git a/resources/com/meesho/php-values.yaml b/resources/com/homelab/php-values.yaml similarity index 99% rename from resources/com/meesho/php-values.yaml rename to resources/com/homelab/php-values.yaml index cf1f91c..f4efe23 100644 --- a/resources/com/meesho/php-values.yaml +++ b/resources/com/homelab/php-values.yaml @@ -98,7 +98,7 @@ externalSecret: annotations: <% if (external_secrets_annotations) {external_secrets_annotations.each{k,v -> println " ${k}: ${v}"};} else {print ''} %> enabled: true - path: meesho/${vault_env}/${bu}/${team}/${app_name} + path: homelab/${vault_env}/${bu}/${team}/${app_name} version: ${tag} name: ${env_ns}-${app_name} target: ${app_name} diff --git a/resources/com/meesho/python-2.7-Dockerfile b/resources/com/homelab/python-2.7-Dockerfile similarity index 100% rename from resources/com/meesho/python-2.7-Dockerfile rename to resources/com/homelab/python-2.7-Dockerfile diff --git a/resources/com/meesho/python-3.10.12-Dockerfile b/resources/com/homelab/python-3.10.12-Dockerfile similarity index 100% rename from resources/com/meesho/python-3.10.12-Dockerfile rename to resources/com/homelab/python-3.10.12-Dockerfile diff --git a/resources/com/meesho/python-3.13-Dockerfile b/resources/com/homelab/python-3.13-Dockerfile similarity index 100% rename from resources/com/meesho/python-3.13-Dockerfile rename to resources/com/homelab/python-3.13-Dockerfile diff --git a/resources/com/meesho/python-3.7-Dockerfile b/resources/com/homelab/python-3.7-Dockerfile similarity index 100% rename from resources/com/meesho/python-3.7-Dockerfile rename to resources/com/homelab/python-3.7-Dockerfile diff --git a/resources/com/homelab/python-Dockerfile b/resources/com/homelab/python-Dockerfile new file mode 100644 index 0000000..d8fd5e2 --- /dev/null +++ b/resources/com/homelab/python-Dockerfile @@ -0,0 +1,12 @@ +# Fallback only — see go-Dockerfile's header comment for the general +# rule. Simplified from the real python-*-Dockerfile set (which had four +# separate version-pinned files, 2.7/3.7/3.10.12/3.13) into one +# version-parametrized template. Assumes a standard requirements.txt + +# app.py (Flask/FastAPI-style `app:app` target for gunicorn) repo. +FROM python:${version}-slim +WORKDIR /app +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt +COPY . . +EXPOSE 8080 +CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"] diff --git a/resources/com/meesho/python-deployment.yaml b/resources/com/homelab/python-deployment.yaml similarity index 100% rename from resources/com/meesho/python-deployment.yaml rename to resources/com/homelab/python-deployment.yaml diff --git a/resources/com/meesho/python-values.yaml b/resources/com/homelab/python-values.yaml similarity index 97% rename from resources/com/meesho/python-values.yaml rename to resources/com/homelab/python-values.yaml index 205db89..56a5cf7 100644 --- a/resources/com/meesho/python-values.yaml +++ b/resources/com/homelab/python-values.yaml @@ -103,7 +103,7 @@ externalSecret: annotations: <% if (external_secrets_annotations) {external_secrets_annotations.each{k,v -> println " ${k}: ${v}"};} else {print ''} %> enabled: true - path: meesho/${vault_env}/${bu}/${team}/${app_name} + path: homelab/${vault_env}/${bu}/${team}/${app_name} version: ${tag} name: ${env_ns}-${app_name} target: ${app_name} @@ -159,8 +159,8 @@ statefulset: enabled: <% if (kind == "statefulset" || kind == "StatefulSet" || kind == "statefulSet") { print "true" } else { print "false" } %> updateStrategy: <% if (statefulset.updateStrategy == "RollingUpdate" || statefulset.updateStrategy == "rollingUpdate" || statefulset.updateStrategy == "rollingupdate") { print "RollingUpdate" } else { print "null" } %> volumeType: ${statefulset.volumeType} -<% if(statefulset.volumeType == "static" || statefulset.volumeType == "Static") { println " staticVolume:"; statefulset.staticVolume.each{k,v -> println " ${k}: ${v}"};} else {print " staticVolume:\n accessMode: ReadWriteMany\n mountPath: /opt/data\n size: 5Gi\n storageClass: meesho-gp2\n volumeHandle: fs-0e2a97a38b01857d1::fsap-07b146e3bc7aef280\n csiDriver: efs.csi.aws.com"} %> -<% if(statefulset.volumeType == "dynamic" || statefulset.volumeType == "Dynamic") { println " dynamicVolume:"; statefulset.dynamicVolume.each{k,v -> println " ${k}: ${v}"};} else {print " dynamicVolume:\n accessMode: ReadWriteMany\n mountPath: /opt/data\n size: 5Gi\n storageClass: meesho-gp2"} %> +<% if(statefulset.volumeType == "static" || statefulset.volumeType == "Static") { println " staticVolume:"; statefulset.staticVolume.each{k,v -> println " ${k}: ${v}"};} else {print " staticVolume:\n accessMode: ReadWriteMany\n mountPath: /opt/data\n size: 5Gi\n storageClass: homelab-gp2\n volumeHandle: fs-0e2a97a38b01857d1::fsap-07b146e3bc7aef280\n csiDriver: efs.csi.aws.com"} %> +<% if(statefulset.volumeType == "dynamic" || statefulset.volumeType == "Dynamic") { println " dynamicVolume:"; statefulset.dynamicVolume.each{k,v -> println " ${k}: ${v}"};} else {print " dynamicVolume:\n accessMode: ReadWriteMany\n mountPath: /opt/data\n size: 5Gi\n storageClass: homelab-gp2"} %> createContourGateway: <% if (createContourGateway) { print "${createContourGateway}" } else { print "false" } %> contourResponseTimeout: ${contourResponseTimeout} podtemplate: diff --git a/resources/com/meesho/rust-Dockerfile b/resources/com/homelab/rust-Dockerfile similarity index 94% rename from resources/com/meesho/rust-Dockerfile rename to resources/com/homelab/rust-Dockerfile index 78fbff7..d1ef434 100644 --- a/resources/com/meesho/rust-Dockerfile +++ b/resources/com/homelab/rust-Dockerfile @@ -34,7 +34,7 @@ RUN cargo build --workspace --release # Clean up SSH key from builder stage for security RUN rm -rf /root/.ssh/ -FROM asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/build/debian:trixie-slim +FROM asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/build/debian:trixie-slim # Install runtime dependencies if your app needs them (e.g., SSL) RUN apt-get update && apt-get install -y --no-install-recommends \ diff --git a/resources/com/meesho/rust-values.yaml b/resources/com/homelab/rust-values.yaml similarity index 99% rename from resources/com/meesho/rust-values.yaml rename to resources/com/homelab/rust-values.yaml index 4b26f08..338a5be 100644 --- a/resources/com/meesho/rust-values.yaml +++ b/resources/com/homelab/rust-values.yaml @@ -108,7 +108,7 @@ externalSecret: annotations: <% if (external_secrets_annotations) {external_secrets_annotations.each{k,v -> println " ${k}: ${v}"};} else {print ''} %> enabled: true - path: meesho/${vault_env}/${bu}/${team}/${app_name} + path: homelab/${vault_env}/${bu}/${team}/${app_name} version: ${tag} name: ${env_ns}-${app_name} target: ${app_name} diff --git a/resources/com/meesho/validate_configs.py b/resources/com/homelab/validate_configs.py similarity index 99% rename from resources/com/meesho/validate_configs.py rename to resources/com/homelab/validate_configs.py index 6b79d32..cc7c289 100644 --- a/resources/com/meesho/validate_configs.py +++ b/resources/com/homelab/validate_configs.py @@ -25,15 +25,15 @@ merger = Merger( deployable_section_format = "" invalid_patterns = { - 'stg': ['int.meesho.int', 'prd.meesho.int'], - 'int': ['stg.meesho.int'], - 'prd': ['int.meesho.int', 'stg.meesho.int'] + 'stg': ['int.homelab.int', 'prd.homelab.int'], + 'int': ['stg.homelab.int'], + 'prd': ['int.homelab.int', 'stg.homelab.int'] } valid_zk_patterns = { -'dev': ['dev.meesho.int:2181'], - 'stg': ['dev.meesho.int:2181'], - 'int': ['int.meesho.int:2181'], - 'prd': ['config.prd.meesho.int:2181','mlp.prd.meesho.int:2181','comms.prd.meesho.int:2181'] +'dev': ['dev.homelab.int:2181'], + 'stg': ['dev.homelab.int:2181'], + 'int': ['int.homelab.int:2181'], + 'prd': ['config.prd.homelab.int:2181','mlp.prd.homelab.int:2181','comms.prd.homelab.int:2181'] } whitelists_for_preprod = ['consumer', 'scheduler', 'cron'] diff --git a/resources/com/meesho/validate_configs_v2.py b/resources/com/homelab/validate_configs_v2.py similarity index 98% rename from resources/com/meesho/validate_configs_v2.py rename to resources/com/homelab/validate_configs_v2.py index 3b8ee64..ab13468 100644 --- a/resources/com/meesho/validate_configs_v2.py +++ b/resources/com/homelab/validate_configs_v2.py @@ -25,15 +25,15 @@ merger = Merger( deployable_section_format = "" invalid_patterns = { - 'stg': ['int.meesho.int', 'prd.meesho.int'], - 'int': ['stg.meesho.int'], - 'prd': ['int.meesho.int', 'stg.meesho.int'] + 'stg': ['int.homelab.int', 'prd.homelab.int'], + 'int': ['stg.homelab.int'], + 'prd': ['int.homelab.int', 'stg.homelab.int'] } valid_zk_patterns = { -'dev': ['dev.meesho.int:2181', 'dev.meesho.int'], - 'stg': ['dev.meesho.int:2181', 'dev.meesho.int'], - 'int': ['int.meesho.int:2181', 'int.meesho.int'], - 'prd': ['config.prd.meesho.int:2181','mlp.prd.meesho.int:2181','comms.prd.meesho.int:2181', 'config.prd.meesho.int','mlp.prd.meesho.int','comms.prd.meesho.int'] +'dev': ['dev.homelab.int:2181', 'dev.homelab.int'], + 'stg': ['dev.homelab.int:2181', 'dev.homelab.int'], + 'int': ['int.homelab.int:2181', 'int.homelab.int'], + 'prd': ['config.prd.homelab.int:2181','mlp.prd.homelab.int:2181','comms.prd.homelab.int:2181', 'config.prd.homelab.int','mlp.prd.homelab.int','comms.prd.homelab.int'] } whitelists_for_preprod = ['consumer', 'scheduler', 'cron'] diff --git a/resources/com/meesho/values.yaml b/resources/com/homelab/values.yaml similarity index 99% rename from resources/com/meesho/values.yaml rename to resources/com/homelab/values.yaml index a07f21f..3f5f5f8 100644 --- a/resources/com/meesho/values.yaml +++ b/resources/com/homelab/values.yaml @@ -130,7 +130,7 @@ externalSecret: annotations: <% if (external_secrets_annotations) {external_secrets_annotations.each{k,v -> println " ${k}: ${v}"};} else {print ''} %> enabled: true - path: meesho/${vault_env}/${bu}/${team}/${app_name} + path: homelab/${vault_env}/${bu}/${team}/${app_name} version: ${tag} name: ${env_ns}-${app_name} target: ${app_name} diff --git a/resources/com/meesho/values_properties.yaml b/resources/com/homelab/values_properties.yaml similarity index 100% rename from resources/com/meesho/values_properties.yaml rename to resources/com/homelab/values_properties.yaml diff --git a/resources/com/meesho/Jenkinsfile b/resources/com/meesho/Jenkinsfile deleted file mode 100644 index ae3071c..0000000 --- a/resources/com/meesho/Jenkinsfile +++ /dev/null @@ -1,3 +0,0 @@ -@Library('devops-lib') _ - -eksCICD repo_name: "${repo_name}" diff --git a/resources/com/meesho/go-Dockerfile b/resources/com/meesho/go-Dockerfile deleted file mode 100644 index 6942523..0000000 --- a/resources/com/meesho/go-Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -# tools and packages from base image -FROM ${build_registry}/build/golang:${version}-alpine3.18${kafka} AS builder - -<% if(module_property.kafka) { println "ENV GOPROXY=${go_proxy},direct CGO_ENABLED=1 GOOS=linux"} else { println "ENV GOPROXY=${go_proxy},direct CGO_ENABLED=0 GOOS=linux"} %> - -# Following steps will help in downloading dependencies for the project -COPY id_github_jenkins /root/.ssh/id_rsa - -RUN chmod 600 /root/.ssh/id_rsa && \ -ssh-keyscan github.com >> /root/.ssh/known_hosts && \ -git config --global url."git@github.com:".insteadOf "https://github.com/" - -# The tar file contains only the go.mod and go.sum files, it is generated as part of Jenkins build. -ADD only-mods.tar /app/ - -# directory inside container and default destination for all subsequent commands -<% if (base_dir) { println "WORKDIR /app/${base_dir}"} else { println "WORKDIR /app/"} %> - -# downloading all the dependencies -RUN --mount=type=cache,target=/go/pkg/mod,id=${repo_name} \ - --mount=type=cache,target=/root/.cache/go-build,id=${repo_name}-build \ - go env -w GOPRIVATE=github.com/Meesho/* && go mod download - -# copying the source code -COPY . /app/ - -# building the code for linux OS -RUN --mount=type=cache,target=/go/pkg/mod,id=${repo_name} \ - --mount=type=cache,target=/root/.cache/go-build,id=${repo_name}-build \ - go mod tidy && go build -tags musl --ldflags "-extldflags -static" -v -o /app/server cmd/${module}/main.go - -# deploy multistage -FROM ${build_registry}/build/debian:10-slim-v1 - -# install an up-to-date, properly rehashed CA trust store in the runtime image -# instead of copying the stale Alpine builder bundle (DEVOPS-30300) -RUN apt-get update \ - && apt-get install -y --no-install-recommends ca-certificates \ - && update-ca-certificates \ - && rm -rf /var/lib/apt/lists/* - -# copy the binary to the production image from the builder stage. -COPY --from=builder /app/server /app/server -<% if (copy_file) { print "COPY copied_files/* $copy_target" } %> -<% add_files.each { print "COPY ${it.path} ${it.target}\n" } %> -# running the binary -CMD ["/app/server"] diff --git a/resources/com/meesho/java-Dockerfile b/resources/com/meesho/java-Dockerfile deleted file mode 100644 index bcd4726..0000000 --- a/resources/com/meesho/java-Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -# This sample, non-production-ready template describes an Amazon EC2 instance and an Elastic Load Balancer. -# © 2020 Amazon Web Services, Inc. or its affiliates. All Rights Reserved. -# This AWS Content is provided subject to the terms of the AWS Customer Agreement available at -# http://aws.amazon.com/agreement or other written agreement between Customer and either -# Amazon Web Services, Inc. or Amazon Web Services EMEA SARL or both. - -FROM ${buildRegistry}/build/java:${dockerBuildVersion} - -ARG artifactId=<% print module=='module_less'?repo_name:module %> -ARG XMS=2G -ARG XMX=2G - -ADD https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.15.0/jmx_prometheus_javaagent-0.15.0.jar /opt/jmx_exporter.jar -#ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.17.0/opentelemetry-javaagent.jar /opt/opentelemetry-javaagent.jar - -ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.26.0/opentelemetry-javaagent.jar /opt/opentelemetry-javaagent.jar - -EXPOSE 8880 8010 - -COPY <% print module=='module_less'?'':module+"/" %>target/*.jar /opt/target/<% print '$artifactId' %>.jar -#RUN mkdir -p /var/log/<% print '$artifactId' %> && touch /var/log/<% print '$artifactId' %>/gc.log -<% add_files.each { print "COPY ${it.path} ${it.target}\n" } %> -<% if (copy_file) { print "COPY copied_files/* $copy_target"} %> - -WORKDIR /opt/target - -CMD ["<% print '$artifactId' %>.jar", "-javaagent:/opt/jmx_exporter.jar=8880:/opt/config/jmx-config.yaml", \\ - "-XX:MinRAMPercentage=50.0", "-XX:MaxRAMPercentage=80.0", \\ - "-XX:+UseParallelGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails", \\ - "-XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime", "-XX:+PrintHeapAtGC", \\ - "-Xloggc:/var/log/gc.log", \\ - "-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=9000k", \\ - "-Xms<% print '$XMS'%>", "-Xmx<% print '$XMX'%>"] diff --git a/resources/com/meesho/node-Dockerfile b/resources/com/meesho/node-Dockerfile deleted file mode 100644 index 4c1d08a..0000000 --- a/resources/com/meesho/node-Dockerfile +++ /dev/null @@ -1,58 +0,0 @@ -FROM ${buildRegistry}/build/node:${version}-slim-secure-multiarch_v2.0 as build-env - -WORKDIR /usr/src/app - -COPY id_github_jenkins /root/.ssh/id_rsa - -RUN ssh-keyscan github.com >> /root/.ssh/known_hosts - -COPY . ./ -<% add_files.each { print "COPY ${it.path} ${it.target}\n" } %> - -RUN ls -al && \ - echo 'NPM Install...' && \ - <% if (npm_install_arg) { %>\ - echo 'Using custom npm install command: ${npm_install_arg}' && \ - ${npm_install_arg} && \ - <% } else { %>\ - npm ci && \ - <% } %>\ - echo 'Ensuring .npmrc is available in subdirectories...' && \ - for subdir in server client; do \ - if [ -d "\$subdir" ] && [ -f .npmrc ] && [ ! -f "\$subdir/.npmrc" ]; then \ - cp -v .npmrc "\$subdir/.npmrc"; \ - fi; \ - done && \ - <% if (pbac_enabled) { %>\ - echo 'Installing PBAC Registry Sync CLI...' && \ - git config --global url."git@github.com:".insteadOf "https://github.com/" && \ - npm install -g pbac-registry-sync-cli --registry=${npm_registry} && \ - echo 'Syncing PBAC Registry for scope: ${pbac_scope_name} environment: ${pbac_env}' && \ - sync-pbac-registry ${pbac_scope_name} ${pbac_env} && \ - echo 'PBAC Registry Sync Completed' && \ - echo 'Copying .npmrc to subdirectories for proper registry resolution...' && \ - for subdir in server client; do \ - if [ -d "\$subdir" ] && [ ! -f "\$subdir/.npmrc" ]; then \ - cp -v .npmrc "\$subdir/.npmrc"; \ - fi; \ - done && \ - <% } %>\ - if ! ${skip_sonar}; then \ - cat .env | grep 'SONAR_' && \ - echo 'Installing Java 17...' && \ - if [ "\$(cat /etc/os-release | grep 'ID=' | awk -F= '{print \$2}' | sed '2d')" = 'alpine' ]; then \ - echo "Alpine" && \ - apk add --no-cache openjdk17; \ - else \ - echo "Debian" && \ - apt-get update && \ - apt-get install -y --no-install-recommends openjdk-17-jre && \ - apt-get clean; \ - fi && \ - echo 'Performing Test Coverage...' && \ - npm run ${testCMD} || true && \ - echo 'Static Analysis...' && \ - npm run sonar -- source=${scmType}; \ - fi && \ - echo 'NPM build...' && \ - npm run build diff --git a/resources/com/meesho/php-Dockerfile b/resources/com/meesho/php-Dockerfile deleted file mode 100644 index aa9784a..0000000 --- a/resources/com/meesho/php-Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -FROM php:7.0.33-apache -RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list - -RUN apt-get update && \ - apt-get install -y libxml2-dev && \ - apt-get install -y libssl-dev && \ - apt-get install -y libedit-dev && \ - apt-get install -y libpq-dev && \ - apt-get install -y libxslt1-dev && \ - apt-get install -y zlib1g-dev && \ - apt-get install -y libxml2-dev - -RUN docker-php-ext-install xml xmlwriter mysqli pdo pdo_mysql opcache json calendar fileinfo ctype dom exif ftp gettext iconv pgsql phar posix readline shmop simplexml sockets sysvmsg sysvsem sysvshm tokenizer wddx xsl pdo_pgsql - -RUN mkdir -p /home/ubuntu/billion_dollar/supply_api -RUN mkdir -p /home/ubuntu/billion_dollar/supply_api/logs/ - -COPY ./ /home/ubuntu/billion_dollar/supply_api -<% if (copy_file) { print "COPY copied_files/apache2/ ${copy_target}\nRUN mkdir -p /etc/phpmyadmin && mv ${copy_target}phpmyadmin_apache.conf /etc/phpmyadmin/apache.conf"} %> -<% add_files.each { print "COPY ${it.path} ${it.target}\n" } %> - -WORKDIR /home/ubuntu/billion_dollar/supply_api -RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini -RUN echo "date.timezone=Asia/Kolkata" >> /usr/local/etc/php/php.ini - -RUN chmod 755 /home/ubuntu/billion_dollar/supply_api - -RUN service apache2 restart - -RUN rm /etc/apache2/sites-enabled/000-default.conf && \ - rm /etc/apache2/sites-available/000-default.conf && \ - chmod -R 755 /home/ubuntu/billion_dollar/supply_api/api && \ - chmod 644 /home/ubuntu/billion_dollar/supply_api/api/.htaccess - -CMD ["apache2-foreground"] diff --git a/resources/org/meesho/dev-pod.yaml b/resources/org/homelab/dev-pod.yaml similarity index 89% rename from resources/org/meesho/dev-pod.yaml rename to resources/org/homelab/dev-pod.yaml index 7c84c89..6be3ae9 100644 --- a/resources/org/meesho/dev-pod.yaml +++ b/resources/org/homelab/dev-pod.yaml @@ -13,7 +13,7 @@ spec: serviceAccountName: jenkins-dev-agent containers: - name: devops-tools - image: asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.22 + image: asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.22 imagePullPolicy: Always resources: requests: diff --git a/resources/org/homelab/dind-pod.yaml b/resources/org/homelab/dind-pod.yaml new file mode 100644 index 0000000..bc7deca --- /dev/null +++ b/resources/org/homelab/dind-pod.yaml @@ -0,0 +1,54 @@ +# New resource — didn't exist in the original devops-lib. Homelab's real +# pipelines built on static agents (node('slave02')) with Docker already +# available; this homelab's Jenkins uses dynamic per-build Kubernetes +# agents (agent.enabled in the jenkins chart), which don't have a Docker +# daemon by default. This pod template adds one as a sidecar container — +# the "docker" container runs privileged dind, "docker-cli" is what the +# pipeline actually execs into via container('docker-cli'), talking to +# its sibling over localhost since containers in one pod share a network +# namespace. +apiVersion: v1 +kind: Pod +spec: + containers: + - name: docker + image: docker:27-dind + securityContext: + privileged: true + env: + - name: DOCKER_TLS_CERTDIR + value: "" + volumeMounts: + - name: docker-graph-storage + mountPath: /var/lib/docker + - name: docker-cli + image: docker:27-cli + command: ["cat"] + tty: true + env: + - name: DOCKER_HOST + value: tcp://localhost:2375 + # For syncArgoApp.groovy — read directly from the ESO-managed + # Secret, not a Jenkins-native credential (nothing in this + # pipeline uses Jenkins' own credential store; staying consistent + # rather than mixing the two approaches). + - name: ARGOCD_TOKEN + valueFrom: + secretKeyRef: + name: argocd-jenkins-ci-token + key: token + # Without this, every build using this pod template hard-fails + # to even start until the token secret exists — including the + # very first demo-go-app run, before the manual + # `argocd account generate-token` bootstrap step has happened. + optional: true + volumeMounts: + - name: docker-config + mountPath: /root/.docker + readOnly: true + volumes: + - name: docker-graph-storage + emptyDir: {} + - name: docker-config + secret: + secretName: harbor-robot-dockerconfig diff --git a/resources/org/meesho/prd-pod.yaml b/resources/org/homelab/prd-pod.yaml similarity index 89% rename from resources/org/meesho/prd-pod.yaml rename to resources/org/homelab/prd-pod.yaml index 379e5bf..ada4c19 100644 --- a/resources/org/meesho/prd-pod.yaml +++ b/resources/org/homelab/prd-pod.yaml @@ -14,7 +14,7 @@ spec: containers: - name: devops-tools - image: asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.22 + image: asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.22 imagePullPolicy: Always resources: diff --git a/resources/org/meesho/prd-sidecar-pod.yaml b/resources/org/homelab/prd-sidecar-pod.yaml similarity index 86% rename from resources/org/meesho/prd-sidecar-pod.yaml rename to resources/org/homelab/prd-sidecar-pod.yaml index 6a37ca2..5919a15 100644 --- a/resources/org/meesho/prd-sidecar-pod.yaml +++ b/resources/org/homelab/prd-sidecar-pod.yaml @@ -13,7 +13,7 @@ spec: serviceAccountName: jenkins-prd-agent containers: - name: devops-tools - image: asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.21 + image: asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.21 imagePullPolicy: Always resources: requests: @@ -36,7 +36,7 @@ spec: tty: true - name: dind - image: asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/devops/docker:28-dind + image: asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/devops/docker:28-dind securityContext: privileged: true env: diff --git a/resources/org/meesho/stg-pod.yaml b/resources/org/homelab/stg-pod.yaml similarity index 89% rename from resources/org/meesho/stg-pod.yaml rename to resources/org/homelab/stg-pod.yaml index 85bbd4a..8732355 100644 --- a/resources/org/meesho/stg-pod.yaml +++ b/resources/org/homelab/stg-pod.yaml @@ -13,7 +13,7 @@ spec: serviceAccountName: jenkins-dev-agent containers: - name: devops-tools - image: asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.22 + image: asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.22 imagePullPolicy: Always resources: requests: diff --git a/resources/org/meesho/stg-sidecar-pod.yaml b/resources/org/homelab/stg-sidecar-pod.yaml similarity index 86% rename from resources/org/meesho/stg-sidecar-pod.yaml rename to resources/org/homelab/stg-sidecar-pod.yaml index 31c8a33..e42cb8a 100644 --- a/resources/org/meesho/stg-sidecar-pod.yaml +++ b/resources/org/homelab/stg-sidecar-pod.yaml @@ -13,7 +13,7 @@ spec: serviceAccountName: jenkins-dev-agent containers: - name: devops-tools - image: asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.21 + image: asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.21 imagePullPolicy: Always resources: requests: @@ -36,7 +36,7 @@ spec: tty: true - name: dind - image: asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/devops/docker:28-dind + image: asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/devops/docker:28-dind securityContext: privileged: true env: diff --git a/resources/org/meesho/templates/maven-3.3-jdk-8.sh b/resources/org/homelab/templates/maven-3.3-jdk-8.sh similarity index 95% rename from resources/org/meesho/templates/maven-3.3-jdk-8.sh rename to resources/org/homelab/templates/maven-3.3-jdk-8.sh index 3e0ebfd..d211be6 100644 --- a/resources/org/meesho/templates/maven-3.3-jdk-8.sh +++ b/resources/org/homelab/templates/maven-3.3-jdk-8.sh @@ -38,10 +38,10 @@ cat << EOF > Dockerfile-${artifactId} # http://aws.amazon.com/agreement or other written agreement between Customer and either # Amazon Web Services, Inc. or Amazon Web Services EMEA SARL or both. FROM 766380763301.dkr.ecr.ap-south-1.amazonaws.com/build/maven:3.3-jdk-8 as BUILD -#FROM asia-southeast1-docker.pkg.dev/supply-poc-351106/meesho-devops/maven:3.3-jdk-8 as BUILD +#FROM asia-southeast1-docker.pkg.dev/supply-poc-351106/homelab-devops/maven:3.3-jdk-8 as BUILD RUN mkdir -p /var/log/${artifactId} && touch /var/log/${artifactId}/gc.log FROM 766380763301.dkr.ecr.ap-south-1.amazonaws.com/build/java:8-jdk-slim-secure_v1.0 -#FROM asia-southeast1-docker.pkg.dev/supply-poc-351106/meesho-devops/java:8 +#FROM asia-southeast1-docker.pkg.dev/supply-poc-351106/homelab-devops/java:8 ADD https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.15.0/jmx_prometheus_javaagent-0.15.0.jar /opt/jmx_exporter.jar ### Config added through configmap # COPY config.yaml /opt/config.yaml diff --git a/resources/org/meesho/templates/node-12.22.sh b/resources/org/homelab/templates/node-12.22.sh similarity index 100% rename from resources/org/meesho/templates/node-12.22.sh rename to resources/org/homelab/templates/node-12.22.sh diff --git a/resources/org/meesho/toolchain-pod.yaml b/resources/org/homelab/toolchain-pod.yaml similarity index 90% rename from resources/org/meesho/toolchain-pod.yaml rename to resources/org/homelab/toolchain-pod.yaml index 0e8d375..d32c114 100644 --- a/resources/org/meesho/toolchain-pod.yaml +++ b/resources/org/homelab/toolchain-pod.yaml @@ -13,7 +13,7 @@ spec: serviceAccountName: jenkins-toolchain-dev-agent containers: - name: devops-tools - image: asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.22 + image: asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/devops/build-tools:lunar-v2.0.22 imagePullPolicy: Always resources: requests: diff --git a/src/com/meesho/stages/automationTest.groovy b/src/com/homelab/stages/automationTest.groovy similarity index 93% rename from src/com/meesho/stages/automationTest.groovy rename to src/com/homelab/stages/automationTest.groovy index b261682..fc2eb40 100644 --- a/src/com/meesho/stages/automationTest.groovy +++ b/src/com/homelab/stages/automationTest.groovy @@ -1,6 +1,6 @@ -package com.meesho.stages +package com.homelab.stages -import com.meesho.stages.deployJar +import com.homelab.stages.deployJar def run(Map config){ @@ -22,7 +22,7 @@ def run(Map config){ def checkoutAutomationRepo(String automation_repo_name, String branch){ try{ stage('Checkout automation repo'){ - sh "rm -rf ${automation_repo_name}; git clone git@github.com:Meesho/${automation_repo_name}.git -b ${branch}" + sh "rm -rf ${automation_repo_name}; git clone git@github.com:Homelab/${automation_repo_name}.git -b ${branch}" echo "automation repo cloned" } } diff --git a/src/com/homelab/stages/buildDocker.groovy b/src/com/homelab/stages/buildDocker.groovy new file mode 100644 index 0000000..e736c35 --- /dev/null +++ b/src/com/homelab/stages/buildDocker.groovy @@ -0,0 +1,77 @@ +package com.homelab.stages + +import com.homelab.utilities.constructTemplate + +// Rewritten for this homelab. The original's run() delegated to a +// language-specific build object (buildNode/buildPython/etc.) and its +// release() function drove ArgoCD sync via Ringmaster, Slack, CDN +// invalidation, GCP/AWS branching — none of that applies to one solo app +// on one cluster. Tag bumping in the target Helm chart is its own +// separate stage now (updateHelmTag.groovy) rather than bundled in here. +// +// Kept faithfully: the real buildGo.groovy's fallback rule (line ~156) +// — if the repo has no Dockerfile, render one from a language template; +// if it does, just use it. That fallback now covers go/node/python/ +// java/php (matching resources/com/homelab/-Dockerfile), selected +// via config.dockerBuildVersion — e.g. 'go-1.22', 'node-20', +// 'python-3.12', 'java-21', 'php-8.3'. Simplified versions of the real +// templates: no Homelab private-registry/SSH-keyed module auth, no Sonar, +// no JFrog — see each template's own header comment. +def run(Map config) { + def tag = "${env.BUILD_NUMBER}-${env.GIT_COMMIT?.take(7) ?: 'dev'}" + env.TAG = tag + def image = "harbor-core.harbor.svc.cluster.local/${config.harbor_project}/${config.repo_name}:${tag}" + try { + stage(stageName('Build & push image')) { + container('docker-cli') { + dir("${config.repo_name}") { + if (!fileExists('Dockerfile')) { + renderDockerfile(config) + } + sh "docker build -t ${image} ." + sh "docker push ${image}" + } + } + } + } + catch (Exception e) { + env.msg = 'Error building/pushing image. Error: ' + e.toString() + log.error(env.msg) + currentBuild.result = env.FAILURE + throw e + } + return tag +} + +// Only reached when the repo has no Dockerfile of its own. Requires +// config.dockerBuildVersion (e.g. 'go-1.22') — there's no sensible +// default to fall back to if a repo has neither a Dockerfile nor this +// set, unlike every other config key in this pipeline. +def renderDockerfile(Map config) { + if (!config.dockerBuildVersion) { + error("buildDocker: no Dockerfile in repo and config.dockerBuildVersion not set — can't pick a base image. Either add a Dockerfile to the repo, or set dockerBuildVersion (e.g. 'go-1.22') in config.yaml or the Jenkinsfile call.") + } + def parts = config.dockerBuildVersion.split('-', 2) + def lang = parts[0] + def version = parts.size() > 1 ? parts[1] : null + + def templates = [ + go : ['go-Dockerfile', '1.22'], + node : ['node-Dockerfile', '20'], + python: ['python-Dockerfile', '3.12'], + java : ['java-Dockerfile', '21'], + maven : ['java-Dockerfile', '21'], + php : ['php-Dockerfile', '8.3'], + ] + def entry = templates[lang] + if (!entry) { + error("buildDocker: unrecognised language '${lang}' in dockerBuildVersion '${config.dockerBuildVersion}'. Supported: ${templates.keySet().join(', ')}. Or just add a Dockerfile to the repo instead — that always takes priority over this fallback.") + } + def (templateFile, defaultVersion) = entry + def resolvedVersion = version ?: defaultVersion + + log.info("buildDocker: no Dockerfile in repo — rendering ${templateFile} for ${lang} ${resolvedVersion}") + def constructObj = new constructTemplate() + constructObj.renderTemplate([version: resolvedVersion], templateFile, 'Dockerfile') + sh 'cat Dockerfile' +} diff --git a/src/com/meesho/stages/buildGo.groovy b/src/com/homelab/stages/buildGo.groovy similarity index 96% rename from src/com/meesho/stages/buildGo.groovy rename to src/com/homelab/stages/buildGo.groovy index c1f0ec6..14f5dff 100644 --- a/src/com/meesho/stages/buildGo.groovy +++ b/src/com/homelab/stages/buildGo.groovy @@ -1,16 +1,16 @@ -package com.meesho.stages +package com.homelab.stages -import com.meesho.utilities.buTeamMapping -import com.meesho.utilities.constructTemplate -import com.meesho.utilities.getDockerParams -import com.meesho.utilities.addSSHKey -import com.meesho.utilities.gitActions -import com.meesho.utilities.constructParam -import com.meesho.utilities.dockerUtilities +import com.homelab.utilities.buTeamMapping +import com.homelab.utilities.constructTemplate +import com.homelab.utilities.getDockerParams +import com.homelab.utilities.addSSHKey +import com.homelab.utilities.gitActions +import com.homelab.utilities.constructParam +import com.homelab.utilities.dockerUtilities def buildDckr(Map config) { - env.GOPRIVATE = 'github.com/Meesho' + env.GOPRIVATE = 'github.com/Homelab' def buTeamMappingObj = new buTeamMapping() def constructObj = new constructTemplate() def dockerParamObj = new getDockerParams() @@ -65,7 +65,7 @@ def buildDckr(Map config) { if (shouldValidateConfig) { log.info('************ Validate Config for CAC application.yml files ************') dir("$repoName") { - writeFile file: 'validate_configs.py', text: libraryResource('com/meesho/validate_configs_v2.py') + writeFile file: 'validate_configs.py', text: libraryResource('com/homelab/validate_configs_v2.py') sh 'python3 validate_configs.py' } } else { @@ -300,7 +300,7 @@ def sonar_scan(String repoName, boolean skipSonarAndQualityGate, String goVersio withCredentials([gitUsernamePassword(credentialsId: "${env.GITHUB_CRED}", gitToolName: 'git-tool')]) { sh "git fetch origin ${env.CHANGE_TARGET}:refs/remotes/origin/${env.CHANGE_TARGET}" } - scannerCommand = "sonar-scanner -Dsonar.projectKey=${repoName} -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Meesho/${repoName} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.go.coverage.reportPaths=./cov.out -Dsonar.ws.timeout=120${exclusions}" + scannerCommand = "sonar-scanner -Dsonar.projectKey=${repoName} -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Homelab/${repoName} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.go.coverage.reportPaths=./cov.out -Dsonar.ws.timeout=120${exclusions}" echo "scannerCommand: ${scannerCommand}" } downloadGoFromJFrog(goVersion) @@ -351,8 +351,8 @@ def downloadGoFromJFrog(String goVersion) { echo "env.cicd_environment: ${env.cicd_environment}" def jfrogUrl = (env.cicd_environment == 'prd' || env.cicd_environment == 'int') ? - 'https://jfrog-prd.meeshogcp.in' : - 'https://jfrog-dev.meeshogcp.in' + 'https://jfrog-prd.homelabgcp.in' : + 'https://jfrog-dev.homelabgcp.in' def repo = 'devops-tools-local' def goTarball = "go${goVersion}.linux-amd64.tar.gz" diff --git a/src/com/meesho/stages/buildGradle.groovy b/src/com/homelab/stages/buildGradle.groovy similarity index 97% rename from src/com/meesho/stages/buildGradle.groovy rename to src/com/homelab/stages/buildGradle.groovy index 0eb2963..1916576 100644 --- a/src/com/meesho/stages/buildGradle.groovy +++ b/src/com/homelab/stages/buildGradle.groovy @@ -1,9 +1,9 @@ -package com.meesho.stages +package com.homelab.stages -import com.meesho.utilities.buTeamMapping -import com.meesho.utilities.constructTemplate -import com.meesho.utilities.getDockerParams -import com.meesho.stages.checkOut +import com.homelab.utilities.buTeamMapping +import com.homelab.utilities.constructTemplate +import com.homelab.utilities.getDockerParams +import com.homelab.stages.checkOut /* Function to define the flow of entire build, this function will call different stages related to maven build @@ -149,10 +149,10 @@ def sonar_scan(String repo_name, boolean skip_sonar) { withSonarQubeEnv(env.sonarEnv) { if (env.CHANGE_ID) { if (env.CLOUD_PROVIDER == 'AWS') { - sh(script: "gradle sonar:sonar -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Meesho/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET}") + sh(script: "gradle sonar:sonar -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Homelab/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET}") } else if (env.CLOUD_PROVIDER == 'GCP') { - sh(script: "gradle sonar:sonar -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Meesho/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET}") + sh(script: "gradle sonar:sonar -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Homelab/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET}") } } else { diff --git a/src/com/meesho/stages/buildMaven.groovy b/src/com/homelab/stages/buildMaven.groovy similarity index 98% rename from src/com/meesho/stages/buildMaven.groovy rename to src/com/homelab/stages/buildMaven.groovy index cf190c2..5cc405a 100644 --- a/src/com/meesho/stages/buildMaven.groovy +++ b/src/com/homelab/stages/buildMaven.groovy @@ -1,12 +1,12 @@ -package com.meesho.stages +package com.homelab.stages -import com.meesho.utilities.buTeamMapping -import com.meesho.utilities.constructTemplate -import com.meesho.utilities.getDockerParams -import com.meesho.stages.checkOut -import com.meesho.utilities.gitActions -import com.meesho.utilities.constructParam -import com.meesho.utilities.dockerUtilities +import com.homelab.utilities.buTeamMapping +import com.homelab.utilities.constructTemplate +import com.homelab.utilities.getDockerParams +import com.homelab.stages.checkOut +import com.homelab.utilities.gitActions +import com.homelab.utilities.constructParam +import com.homelab.utilities.dockerUtilities /* Function to define the flow of entire build, this function will call different stages related to maven build */ @@ -204,7 +204,7 @@ def build(String repo_name, boolean skip_test, String args, String repoType) { if (ValidateConfig) { log.info('************ Validate Config for CAC application.yml files ************') dir("$repo_name") { - writeFile file: 'validate_configs.py', text: libraryResource('com/meesho/validate_configs.py') + writeFile file: 'validate_configs.py', text: libraryResource('com/homelab/validate_configs.py') //Capture output separately, then check status validation_output = sh( script: 'python3 validate_configs.py 2>&1 || true', // || true prevents immediate failure @@ -270,7 +270,7 @@ def build(String repo_name, boolean skip_test, String args, String repoType) { (is_validation_error ? validation_output : e.toString()) - env.msg = "Error Building the maven package. If validate script error then please refer to doc - https://meesho.atlassian.net/wiki/spaces/EW/pages/3915972744/Config+Schema+Validation+Common+Errors+And+Fixes . Also Please check console output for more details - ${e}" + env.msg = "Error Building the maven package. If validate script error then please refer to doc - https://homelab.atlassian.net/wiki/spaces/EW/pages/3915972744/Config+Schema+Validation+Common+Errors+And+Fixes . Also Please check console output for more details - ${e}" env.error_msg_to_db = detailed_error_msg log.error(env.msg) currentBuild.result = env.FAILURE @@ -294,13 +294,13 @@ def sonar_scan(String repo_name, boolean skip_sonar , boolean appConfigChanges) withCredentials([gitUsernamePassword(credentialsId: "${env.GITHUB_CRED}", gitToolName: 'git-tool')]) { sh "git fetch origin ${env.CHANGE_TARGET}:refs/remotes/origin/${env.CHANGE_TARGET}" } - sh(script: "mvn sonar:sonar -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Meesho/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.ws.timeout=120") + sh(script: "mvn sonar:sonar -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Homelab/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.ws.timeout=120") } else if (env.CLOUD_PROVIDER == 'GCP') { withCredentials([gitUsernamePassword(credentialsId: "${env.GITHUB_CRED}", gitToolName: 'git-tool')]) { sh "git fetch origin ${env.CHANGE_TARGET}:refs/remotes/origin/${env.CHANGE_TARGET}" } - sh(script: "mvn sonar:sonar -Dsonar.pullrequest.provider=GitHub -Dsonar.projectName=${repo_name} -Dsonar.pullrequest.github.repository=Meesho/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.ws.timeout=120") + sh(script: "mvn sonar:sonar -Dsonar.pullrequest.provider=GitHub -Dsonar.projectName=${repo_name} -Dsonar.pullrequest.github.repository=Homelab/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.ws.timeout=120") } } else { diff --git a/src/com/meesho/stages/buildNode.groovy b/src/com/homelab/stages/buildNode.groovy similarity index 92% rename from src/com/meesho/stages/buildNode.groovy rename to src/com/homelab/stages/buildNode.groovy index 7d4c2c0..4348cb1 100644 --- a/src/com/meesho/stages/buildNode.groovy +++ b/src/com/homelab/stages/buildNode.groovy @@ -1,11 +1,11 @@ -package com.meesho.stages +package com.homelab.stages -import com.meesho.utilities.buTeamMapping -import com.meesho.utilities.constructTemplate -import com.meesho.utilities.getDockerParams -import com.meesho.utilities.addSSHKey -import com.meesho.utilities.dockerUtilities -import com.meesho.utilities.getYamlParameter +import com.homelab.utilities.buTeamMapping +import com.homelab.utilities.constructTemplate +import com.homelab.utilities.getDockerParams +import com.homelab.utilities.addSSHKey +import com.homelab.utilities.dockerUtilities +import com.homelab.utilities.getYamlParameter def removePackageLock() { sh(script: 'rm -rf package-lock.json') @@ -43,17 +43,17 @@ def getAwsSecret(def secret_name, def destination_file, def team, def bu) { sh(script:"aws secretsmanager get-secret-value --secret-id ${secret_name} --query SecretString --output text > ${destination_file}") } else if (env.CLOUD_PROVIDER == 'GCP') { - getVaultSecret("vault kv get -format=json meesho/${env.cicd_environment}/${bu}/${team}/${secret_name} | jq -r .data.data > ${destination_file}") + getVaultSecret("vault kv get -format=json homelab/${env.cicd_environment}/${bu}/${team}/${secret_name} | jq -r .data.data > ${destination_file}") } } def getNpmRc(def secret_name, def team, def bu) { def npmrc_file = secret_name + '-npmrc-' + env.cicd_environment if (env.CLOUD_PROVIDER == 'AWS') { - sh(script:"aws secretsmanager get-secret-value --secret-id ${npmrc_file} --query SecretString --output text| jq -r .MEESHO_NPMRC_SECRET > .npmrc") + sh(script:"aws secretsmanager get-secret-value --secret-id ${npmrc_file} --query SecretString --output text| jq -r .HOMELAB_NPMRC_SECRET > .npmrc") } else if (env.CLOUD_PROVIDER == 'GCP') { - getVaultSecret("vault kv get -format=json meesho/${env.cicd_environment}/${bu}/${team}/${npmrc_file} | jq -r .data.data.MEESHO_NPMRC_SECRET > .npmrc") + getVaultSecret("vault kv get -format=json homelab/${env.cicd_environment}/${bu}/${team}/${npmrc_file} | jq -r .data.data.HOMELAB_NPMRC_SECRET > .npmrc") } } @@ -64,7 +64,7 @@ def getPemFile(def secret_name, def team, def bu) { sh(script:"aws secretsmanager get-secret-value --secret-id ${pem_secret_name} --query SecretString --output text| jq -r .public_secret_dev > 1_public_secret_dev.pem") } else if (env.CLOUD_PROVIDER == 'GCP') { - getVaultSecret("vault kv get -format=json meesho/${env.cicd_environment}/${bu}/${team}/${pem_secret_name} | jq -r .data.data.public_secret_dev > 1_public_secret_dev.pem") + getVaultSecret("vault kv get -format=json homelab/${env.cicd_environment}/${bu}/${team}/${pem_secret_name} | jq -r .data.data.public_secret_dev > 1_public_secret_dev.pem") } sh(script:"cat 1_public_secret_dev.pem | sed -e 's/-----BEGIN PUBLIC KEY-----/& \\n/' -e 's/-----END PUBLIC KEY-----/\\n-----END PUBLIC KEY-----/g' > public_secret_dev.pem") } @@ -72,7 +72,7 @@ def getPemFile(def secret_name, def team, def bu) { sh(script:"aws secretsmanager get-secret-value --secret-id ${pem_secret_name} --query SecretString --output text| jq -r .public_secret_prod > 1_public_secret_prod.pem") } else if (env.CLOUD_PROVIDER == 'GCP') { - getVaultSecret("vault kv get -format=json meesho/${env.cicd_environment}/${bu}/${team}/${pem_secret_name} | jq -r .data.data.public_secret_prod > 1_public_secret_prod.pem") + getVaultSecret("vault kv get -format=json homelab/${env.cicd_environment}/${bu}/${team}/${pem_secret_name} | jq -r .data.data.public_secret_prod > 1_public_secret_prod.pem") } sh(script:"cat 1_public_secret_prod.pem | sed -e 's/-----BEGIN PUBLIC KEY-----/& \\n/' -e 's/-----END PUBLIC KEY-----/\\n-----END PUBLIC KEY-----/g' > public_secret_prod.pem") @@ -87,8 +87,8 @@ def getEnvFile(def secret_name, def team, def bu, boolean useCacPath = false) { } else if (env.CLOUD_PROVIDER == 'GCP') { def vault_path = useCacPath - ? "meesho/${env.cicd_environment}-cac/${bu}/${team}/${gcp_env_file}-client" - : "meesho/${env.cicd_environment}/${bu}/${team}/${gcp_env_file}" + ? "homelab/${env.cicd_environment}-cac/${bu}/${team}/${gcp_env_file}-client" + : "homelab/${env.cicd_environment}/${bu}/${team}/${gcp_env_file}" getVaultSecret("vault kv get -format=json ${vault_path} | jq -r '.data.data | to_entries|map(\"\\(.key)=\\(.value|tostring)\")|.[]' > .env") } } @@ -212,7 +212,7 @@ def buildDckr(Map config) { // def registry = dparam_obj.getRegistry(env.cicd_environment) def docker_repo = "${env.cicd_environment}/${team}/${repo_name.toLowerCase()}" def push_to_s3 = config.push_to_s3 ?: false - def s3_path = config.s3_path ?: "meesho-${env.BUILD_ENV}-artifacts/${repo_name}/${env.BRANCH_NAME}" + def s3_path = config.s3_path ?: "homelab-${env.BUILD_ENV}-artifacts/${repo_name}/${env.BRANCH_NAME}" if (env.INFRA_ENV == 'toolchain' && env.TOOLCHAIN_ENV) { docker_repo = "${env.cicd_environment}/${env.TOOLCHAIN_ENV}/${team}/${repo_name.toLowerCase()}" log.info("Toolchain: Overriding docker_repo to ${docker_repo}") @@ -351,7 +351,7 @@ def buildDckr(Map config) { if (fileExists('.npmrc')) { npm_registry = sh( returnStdout: true, - script: "grep '^@meesho:registry=' .npmrc | head -1 | cut -d'=' -f2 | tr -d '\\r\\n'" + script: "grep '^@homelab:registry=' .npmrc | head -1 | cut -d'=' -f2 | tr -d '\\r\\n'" ).trim() echo "Detected npm registry: ${npm_registry ?: 'default (none found)'}" } else { @@ -399,7 +399,7 @@ def buildDckr(Map config) { try { dir(repo_name) { addSSHKey.create() - withCredentials([usernamePassword(credentialsId: "svc-devops-meesho-token", usernameVariable: 'GIT_USER', passwordVariable: 'GIT_TOKEN')]) { + withCredentials([usernamePassword(credentialsId: "svc-devops-homelab-token", usernameVariable: 'GIT_USER', passwordVariable: 'GIT_TOKEN')]) { sh """ echo "GITHUB_TOKEN=${GIT_TOKEN}" >> .env echo "GIT_COMMIT_SHA='${commit_sha}'" >> .env @@ -443,7 +443,7 @@ def buildDckr(Map config) { } else if (env.CLOUD_PROVIDER == 'GCP' ) { sh """ - echo 'FROM asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/devops/google-cloud-sdk:458.0.0-alpine as push_env' >> Dockerfile-${artifactId} + echo 'FROM asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/devops/google-cloud-sdk:458.0.0-alpine as push_env' >> Dockerfile-${artifactId} echo 'COPY --from=build-env /usr/src/app /app' >> Dockerfile-${artifactId} # echo 'RUN ls -al /app && find /app/${local_path} -type f \\( -name "*.js" -o -name "*.map" \\) && find /app/${local_path} -type f \\( -name "*.js" -o -name "*.map" \\) | wc -l && gsutil -m cp -r /app/${local_path}* gs://${s3_path}' >> Dockerfile-${artifactId} echo "RUN ls -al /app && gsutil -m rsync -r -x \'${include_s3_files} ${exclude_s3_files}\' /app/${local_path} gs://${s3_path}" >> Dockerfile-${artifactId} @@ -488,7 +488,7 @@ def buildDckr(Map config) { } sh "cat Dockerfile-${artifactId}" def imageList = "${env.buildRegistry}/build/node:${version}-alpine-secure-multiarch_v1.0 " + - "asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin/devops/google-cloud-sdk:458.0.0-alpine " + + "asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin/devops/google-cloud-sdk:458.0.0-alpine " + "${env.buildRegistry}/build/node:${version}-slim-secure-multiarch_v2.0" sh """ @@ -549,8 +549,8 @@ def getVaultSecret(String vault_cmd) { if (env.INFRA_ENV == 'toolchain' && env.TOOLCHAIN_ENV) { boolean skipToolchainOverride = vault_cmd.contains("npmrc") || vault_cmd.contains("-secrets-") if (!skipToolchainOverride) { - vault_cmd = vault_cmd.replace("meesho/${env.cicd_environment}-cac/", "meesho/toolchain/${env.TOOLCHAIN_ENV}/${env.cicd_environment}-cac/") - vault_cmd = vault_cmd.replace("meesho/${env.cicd_environment}/", "meesho/toolchain/${env.TOOLCHAIN_ENV}/${env.cicd_environment}/") + vault_cmd = vault_cmd.replace("homelab/${env.cicd_environment}-cac/", "homelab/toolchain/${env.TOOLCHAIN_ENV}/${env.cicd_environment}-cac/") + vault_cmd = vault_cmd.replace("homelab/${env.cicd_environment}/", "homelab/toolchain/${env.TOOLCHAIN_ENV}/${env.cicd_environment}/") log.info("TOOLCHAIN OVERRIDE (Application Config):") log.info(" New Toolchain Vault CMD: ${vault_cmd}") } else { diff --git a/src/com/meesho/stages/buildObjHelper.groovy b/src/com/homelab/stages/buildObjHelper.groovy similarity index 97% rename from src/com/meesho/stages/buildObjHelper.groovy rename to src/com/homelab/stages/buildObjHelper.groovy index 3aaf055..5695c8b 100644 --- a/src/com/meesho/stages/buildObjHelper.groovy +++ b/src/com/homelab/stages/buildObjHelper.groovy @@ -1,4 +1,4 @@ -package com.meesho.stages +package com.homelab.stages def run(String build_tool){ try { diff --git a/src/com/meesho/stages/buildPhp.groovy b/src/com/homelab/stages/buildPhp.groovy similarity index 96% rename from src/com/meesho/stages/buildPhp.groovy rename to src/com/homelab/stages/buildPhp.groovy index 59d4e6c..19e4c8a 100644 --- a/src/com/meesho/stages/buildPhp.groovy +++ b/src/com/homelab/stages/buildPhp.groovy @@ -1,8 +1,8 @@ -package com.meesho.stages +package com.homelab.stages -import com.meesho.utilities.buTeamMapping -import com.meesho.utilities.constructTemplate -import com.meesho.utilities.getDockerParams +import com.homelab.utilities.buTeamMapping +import com.homelab.utilities.constructTemplate +import com.homelab.utilities.getDockerParams def buildDckr(Map config){ def btObj = new buTeamMapping() diff --git a/src/com/meesho/stages/buildPython.groovy b/src/com/homelab/stages/buildPython.groovy similarity index 95% rename from src/com/meesho/stages/buildPython.groovy rename to src/com/homelab/stages/buildPython.groovy index 45029c3..1b37ce3 100644 --- a/src/com/meesho/stages/buildPython.groovy +++ b/src/com/homelab/stages/buildPython.groovy @@ -1,10 +1,10 @@ -package com.meesho.stages +package com.homelab.stages -import com.meesho.utilities.buTeamMapping -import com.meesho.utilities.constructTemplate -import com.meesho.utilities.getDockerParams -import com.meesho.utilities.addSSHKey -import com.meesho.utilities.dockerUtilities +import com.homelab.utilities.buTeamMapping +import com.homelab.utilities.constructTemplate +import com.homelab.utilities.getDockerParams +import com.homelab.utilities.addSSHKey +import com.homelab.utilities.dockerUtilities /* Function to get the version from pom.xml input arguments: @@ -30,7 +30,7 @@ repo_name: String parameter to change the directory where pom.xml is located // def getNpmRc(def secret_name){ // def npmrc_file = secret_name + "-npmrc" -// sh (script:"aws secretsmanager get-secret-value --secret-id ${npmrc_file} --query SecretString --output text| jq -r .MEESHO_NPMRC_SECRET > .npmrc") +// sh (script:"aws secretsmanager get-secret-value --secret-id ${npmrc_file} --query SecretString --output text| jq -r .HOMELAB_NPMRC_SECRET > .npmrc") // } // def getPemFile(def secret_name){ @@ -156,8 +156,8 @@ def buildDckr(Map config) { // print(config) constructObj.renderTemplate(docker_bindings,config.dockerBuildVersion+'-Dockerfile','Dockerfile-'+repo_name) sh "cat Dockerfile-${repo_name}" - // withCredentials([string(credentialsId: 'meesho-github-ssh-prv-key', variable: 'SSH_PRIVATE_KEY_S')]) { - // withCredentials(bindings: [sshUserPrivateKey(credentialsId: 'meesho-ssh-github-key', \ + // withCredentials([string(credentialsId: 'homelab-github-ssh-prv-key', variable: 'SSH_PRIVATE_KEY_S')]) { + // withCredentials(bindings: [sshUserPrivateKey(credentialsId: 'homelab-ssh-github-key', \ // keyFileVariable: 'SSH_PRIVATE_KEY', \ // passphraseVariable: '', \ // usernameVariable: '')]) { diff --git a/src/com/meesho/stages/buildRust.groovy b/src/com/homelab/stages/buildRust.groovy similarity index 96% rename from src/com/meesho/stages/buildRust.groovy rename to src/com/homelab/stages/buildRust.groovy index aeab669..bd7a0b1 100644 --- a/src/com/meesho/stages/buildRust.groovy +++ b/src/com/homelab/stages/buildRust.groovy @@ -1,14 +1,14 @@ -package com.meesho.stages +package com.homelab.stages -import com.meesho.utilities.buTeamMapping -import com.meesho.utilities.constructTemplate -import com.meesho.utilities.getDockerParams -import com.meesho.utilities.addSSHKey +import com.homelab.utilities.buTeamMapping +import com.homelab.utilities.constructTemplate +import com.homelab.utilities.getDockerParams +import com.homelab.utilities.addSSHKey def buildDckr(Map config) { - env.RUSTPRIVATE = 'github.com/Meesho' + env.RUSTPRIVATE = 'github.com/Homelab' def btObj = new buTeamMapping() def constructObj = new constructTemplate() def dparam_obj = new getDockerParams() @@ -212,7 +212,7 @@ def sonar_scan(String repo_name, boolean skip_sonar , String version ) { withCredentials([gitUsernamePassword(credentialsId: "${env.GITHUB_CRED}", gitToolName: 'git-tool')]) { sh "git fetch origin ${env.CHANGE_TARGET}:refs/remotes/origin/${env.CHANGE_TARGET}" } - sh(script: "mvn sonar:sonar -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Meesho/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET}") + sh(script: "mvn sonar:sonar -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Homelab/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET}") } else if (env.CLOUD_PROVIDER == 'GCP') { withCredentials([gitUsernamePassword(credentialsId: "${env.GITHUB_CRED}", gitToolName: 'git-tool')]) { @@ -239,7 +239,7 @@ def sonar_scan(String repo_name, boolean skip_sonar , String version ) { env.PATH = "/usr/local/sonar-scanner/sonar-scanner-5.0.1.3006-linux/bin:${env.PATH}" // Run Sonar Scanner - sh(script:"sonar-scanner -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Meesho/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.go.coverage.reportPaths=./cov.out ") + sh(script:"sonar-scanner -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=Homelab/${repo_name} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.go.coverage.reportPaths=./cov.out ") } } else { diff --git a/src/com/homelab/stages/checkOut.groovy b/src/com/homelab/stages/checkOut.groovy new file mode 100644 index 0000000..e985727 --- /dev/null +++ b/src/com/homelab/stages/checkOut.groovy @@ -0,0 +1,30 @@ +package com.homelab.stages + +// Adapted from the original: same structure (dir-scoped checkout, +// optional submodule init if .gitmodules exists), just the credential +// default changed from Homelab's internal service account +// (svc-devops-homelab) to this homelab's Gitea credential. Set GITHUB_CRED +// in the pipeline env if you ever need to override it per-job. +def run(Map param) { + try { + stage(stageName('Checkout from git')) { + dir("${param.repo_name}") { + checkout scm + if (fileExists('.gitmodules')) { + log.info('Repository has submodules - running git submodule init and update --recursive') + def credId = env.GITHUB_CRED?.trim() + if (!credId || credId == 'null') credId = 'gitea-ci-credentials' + withCredentials([gitUsernamePassword(credentialsId: credId, gitToolName: 'git-tool')]) { + sh 'git submodule init && git submodule update --recursive' + } + } + } + } + } + catch (Exception e) { + env.msg = 'Error cloning the job. Error: ' + e.toString() + log.error(env.msg) + currentBuild.result = env.FAILURE + throw e + } +} diff --git a/src/com/meesho/stages/deployArgoCD.groovy b/src/com/homelab/stages/deployArgoCD.groovy similarity index 98% rename from src/com/meesho/stages/deployArgoCD.groovy rename to src/com/homelab/stages/deployArgoCD.groovy index 279abc2..be51982 100644 --- a/src/com/meesho/stages/deployArgoCD.groovy +++ b/src/com/homelab/stages/deployArgoCD.groovy @@ -1,14 +1,14 @@ -package com.meesho.stages +package com.homelab.stages import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition -import com.meesho.utilities.getYamlParameter -import com.meesho.utilities.buTeamMapping -import com.meesho.utilities.gitActions -import com.meesho.utilities.constructTemplate -import com.meesho.utilities.constructParam -import com.meesho.utilities.getDockerParams -import com.meesho.utilities.nodePoolSelection +import com.homelab.utilities.getYamlParameter +import com.homelab.utilities.buTeamMapping +import com.homelab.utilities.gitActions +import com.homelab.utilities.constructTemplate +import com.homelab.utilities.constructParam +import com.homelab.utilities.getDockerParams +import com.homelab.utilities.nodePoolSelection def run(String repo_name, def deployment_order, def tag, def build_team, def dockerBuildVersion, String notify_channel) { def userInput = '' @@ -438,7 +438,7 @@ def update_helm_repo(String repo_name, String deployment, String tag, String bui if (criticalPriorities.contains(priority) && (envrn == "prd")) { isDependabotCritcal = dependabotCriticalCheck(repo_name) if (isDependabotCritcal) { - error("Error: Critical vulnerabilities found in repo: " + repo_name + " \nPlease resolve the alerts marked with CRITICAL here and retry: https://github.com/Meesho/" + repo_name + "/security/dependabot and Retry.") + error("Error: Critical vulnerabilities found in repo: " + repo_name + " \nPlease resolve the alerts marked with CRITICAL here and retry: https://github.com/Homelab/" + repo_name + "/security/dependabot and Retry.") } } @@ -483,7 +483,7 @@ def refresh_and_sync(String repo_name, String deployment, String envrn) { def yamlobj = new getYamlParameter() def deploy_values = yamlobj.getParam("${repo_name}/deployments", "${deployment}.yaml") def app_name = deploy_values.app_name - // def argoUrl = (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'main' || env.CHANGE_TARGET == 'master' || env.CHANGE_TARGET == 'main') ? 'prod-ops-argocd.meesho.com' : 'stg-dev-argocd.meeshotest.in' + // def argoUrl = (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'main' || env.CHANGE_TARGET == 'master' || env.CHANGE_TARGET == 'main') ? 'prod-ops-argocd.homelab.com' : 'stg-dev-argocd.homelabtest.in' def argoEnv = (envrn == 'ftr') ? env.ingress_val : envrn log.info('########################### Pulling latest changes in ArgoCD. ###########################') @@ -831,7 +831,7 @@ def validateRequiredMetadata(def bindings) { for (param in serviceOwners) { final String owner = bindings[param] - final String url = "https://pulse.meeshogcp.in/api/anonymous-User/userexist?email=${owner}" + final String url = "https://pulse.homelabgcp.in/api/anonymous-User/userexist?email=${owner}" final def(String response, String code) = sh(returnStdout: true, script: """ set +x curl -s -X GET -w '\n%{response_code}' $url @@ -868,7 +868,7 @@ def dependabotCriticalCheck(def repoName) { [name: 'Accept', value: 'application/vnd.github+json'], [maskValue: true, name: 'Authorization', value: 'Bearer ' + token] ], - url: "https://api.github.com/repos/meesho/${repo}/dependabot/alerts?state=open&per_page=100", + url: "https://api.github.com/repos/homelab/${repo}/dependabot/alerts?state=open&per_page=100", validResponseCodes: '200', timeout: 10 alerts = readJSON(text: validateDependabot.content) diff --git a/src/com/meesho/stages/deployJar.groovy b/src/com/homelab/stages/deployJar.groovy similarity index 92% rename from src/com/meesho/stages/deployJar.groovy rename to src/com/homelab/stages/deployJar.groovy index 9946abf..0a9d254 100644 --- a/src/com/meesho/stages/deployJar.groovy +++ b/src/com/homelab/stages/deployJar.groovy @@ -1,4 +1,4 @@ -package com.meesho.stages +package com.homelab.stages def run(Map param){ //get the jar for deployment, get it from the params module @@ -18,7 +18,7 @@ def deploy(String server_ip, String repo_name, String app_name, String healthche stage('Deploying JAR'){ sh "echo '$server_ip' > host_file.txt" echo "inventory created" - def playbook_content = libraryResource 'com/meesho/deployJar.yaml' + def playbook_content = libraryResource 'com/homelab/deployJar.yaml' writeFile file:"deployJar.yaml", text: playbook_content sh(returnStatus: true, script: "ansible-playbook -i host_file.txt -u 'ubuntu' -e 'env=stage' -e 'app_name=${app_name}' -e 'repo_name=${repo_name}' -e 'healthcheck_api=${healthcheck_api}' -e 'app_port=${app_port}' deployJar.yaml -v") } diff --git a/src/com/meesho/stages/deployRingmaster.groovy b/src/com/homelab/stages/deployRingmaster.groovy similarity index 94% rename from src/com/meesho/stages/deployRingmaster.groovy rename to src/com/homelab/stages/deployRingmaster.groovy index 720f1a8..7d342ef 100644 --- a/src/com/meesho/stages/deployRingmaster.groovy +++ b/src/com/homelab/stages/deployRingmaster.groovy @@ -1,6 +1,6 @@ -package com.meesho.stages +package com.homelab.stages -import com.meesho.utilities.getYamlParameter +import com.homelab.utilities.getYamlParameter import java.time.ZonedDateTime import java.time.format.DateTimeFormatterBuilder @@ -41,10 +41,10 @@ def run(String repo_name, def deployment_order, def tag, def build_team, def doc switch (env.cicd_environment) { case 'prd': case 'int': - baseUrl = 'https://ringmaster-api.meeshogcp.in/api/v1/key/cicd/cd/update' + baseUrl = 'https://ringmaster-api.homelabgcp.in/api/v1/key/cicd/cd/update' break default: - baseUrl = 'https://ringmaster-api.admin.meeshogcp.in/api/v1/key/cicd/cd/update' + baseUrl = 'https://ringmaster-api.admin.homelabgcp.in/api/v1/key/cicd/cd/update' } final String url = "${baseUrl}?workingEnv=${working_env}" final String header = "Content-Type: application/json" @@ -67,10 +67,10 @@ def run(String repo_name, def deployment_order, def tag, def build_team, def doc switch (env.cicd_environment) { case 'prd': case 'int': - cicdBaseUrl = 'http://turbo-turtle.meeshogcp.in' + cicdBaseUrl = 'http://turbo-turtle.homelabgcp.in' break default: - cicdBaseUrl = 'http://turbo-turtle.admin.meeshogcp.in' + cicdBaseUrl = 'http://turbo-turtle.admin.homelabgcp.in' } final String newCICD_JSON = writeJSON returnText: true, json: newCICD_Payload //log.info("New CICD JSON - ${newCICD_JSON}") diff --git a/src/com/meesho/stages/helmGenerator.groovy b/src/com/homelab/stages/helmGenerator.groovy similarity index 94% rename from src/com/meesho/stages/helmGenerator.groovy rename to src/com/homelab/stages/helmGenerator.groovy index 5a95545..cf803a0 100644 --- a/src/com/meesho/stages/helmGenerator.groovy +++ b/src/com/homelab/stages/helmGenerator.groovy @@ -1,10 +1,10 @@ -package com.meesho.stages +package com.homelab.stages -import com.meesho.utilities.constructTemplate -import com.meesho.utilities.gitActions -import com.meesho.utilities.buTeamMapping -import com.meesho.utilities.getDockerParams -import com.meesho.stages.multiBranchPipeline +import com.homelab.utilities.constructTemplate +import com.homelab.utilities.gitActions +import com.homelab.utilities.buTeamMapping +import com.homelab.utilities.getDockerParams +import com.homelab.stages.multiBranchPipeline def run(Map params) { def btObj = new buTeamMapping() @@ -35,8 +35,8 @@ def run(Map params) { def helm_branch_name = it.value for (deployment in deployment_order) { modifiedParams['app_name'] = deployment - modifiedParams['host'] = helm_branch_name == 'feature' ? "INGRESS_PR_NUMBER-${deployment}.dev.internal.meeshotest.in" : "${deployment}.${it.key}.internal.meeshotest.in" - modifiedParams['host'] = (helm_branch_name == 'pre-prod') ? "${deployment}.${modifiedParams.bu}.internal.meesho.co" : modifiedParams.host + modifiedParams['host'] = helm_branch_name == 'feature' ? "INGRESS_PR_NUMBER-${deployment}.dev.internal.homelabtest.in" : "${deployment}.${it.key}.internal.homelabtest.in" + modifiedParams['host'] = (helm_branch_name == 'pre-prod') ? "${deployment}.${modifiedParams.bu}.internal.homelab.co" : modifiedParams.host //If branch is main, then assuming the env as prod //Making nodeSelector changes to hypercore or hypermem & based on arch, so that it moves to common node pool if (helm_branch_name == 'main') { diff --git a/src/com/meesho/stages/hotFix.groovy b/src/com/homelab/stages/hotFix.groovy similarity index 97% rename from src/com/meesho/stages/hotFix.groovy rename to src/com/homelab/stages/hotFix.groovy index c74f5b9..4d47261 100644 --- a/src/com/meesho/stages/hotFix.groovy +++ b/src/com/homelab/stages/hotFix.groovy @@ -1,4 +1,4 @@ -package com.meesho.stages +package com.homelab.stages def run(String repo_name){ stage(stageName("Check for Hot Fix")){ diff --git a/src/com/homelab/stages/loadConfig.groovy b/src/com/homelab/stages/loadConfig.groovy new file mode 100644 index 0000000..c5bb464 --- /dev/null +++ b/src/com/homelab/stages/loadConfig.groovy @@ -0,0 +1,35 @@ +package com.homelab.stages + +// New stage — the homelab equivalent of the real system's config.yaml +// convention. Verified by reading constructParam.groovy directly first: +// it does NOT read config.yaml itself — helmGenerator.groovy renders +// devops-lib's own resources/com/homelab/config.yaml TEMPLATE into each +// SERVICE repo's own root as a real, committed config.yaml, and various +// stages then read that file directly (runHooks.groovy's +// hooks. block, buildNode.groovy's s3_path/pbac_scope_name, etc.). +// +// This is the simplified equivalent: if the checked-out repo has a +// config.yaml at its root, read it and merge its keys into the +// pipeline's config Map — repo-committed values override whatever the +// Jenkinsfile call passed in. Mutates config in place (Groovy Maps are +// passed by reference), so every later stage that already has a +// reference to the same object sees the merge — nothing needs to be +// reassigned or returned. +// +// Entirely optional — a repo with no config.yaml just keeps running on +// the Jenkinsfile call's defaults, same as before this existed. +def run(Map config) { + stage(stageName('Load config.yaml')) { + dir(config.repo_name) { + if (fileExists('config.yaml')) { + def repoConfig = readYaml file: 'config.yaml' + if (repoConfig instanceof Map) { + config.putAll(repoConfig) + log.info("loadConfig: merged config.yaml — keys: ${repoConfig.keySet()}") + } + } else { + log.info('loadConfig: no config.yaml in repo root, using Jenkinsfile call defaults only.') + } + } + } +} diff --git a/src/com/meesho/stages/multiBranchPipeline.groovy b/src/com/homelab/stages/multiBranchPipeline.groovy similarity index 92% rename from src/com/meesho/stages/multiBranchPipeline.groovy rename to src/com/homelab/stages/multiBranchPipeline.groovy index fa6beb1..71ab828 100644 --- a/src/com/meesho/stages/multiBranchPipeline.groovy +++ b/src/com/homelab/stages/multiBranchPipeline.groovy @@ -1,4 +1,4 @@ -package com.meesho.stages +package com.homelab.stages import jxl.* import hudson.util.PersistedList @@ -19,7 +19,7 @@ def applicationOnboard(String foldername, String repo_name) { String folderName = "${foldername}" String repoName = "${repo_name}" String scriptPath = "Jenkinsfile" - String gitRepo = "https://github.com/Meesho/${repo_name}.git" + String gitRepo = "https://github.com/Homelab/${repo_name}.git" String mBPName = "${repo_name}-cicd" String credentialsId = env.GITHUB_CRED @@ -51,7 +51,7 @@ def applicationOnboard(String foldername, String repo_name) { def defaultVersion = "master" def traits = [] - GitHubSCMSource gitHubSCMSource = new GitHubSCMSource("Meesho", repoName, gitRepo, implicit) + GitHubSCMSource gitHubSCMSource = new GitHubSCMSource("Homelab", repoName, gitRepo, implicit) gitHubSCMSource.credentialsId = credentialsId BranchDiscoveryTrait branchDiscoveryTrait = new BranchDiscoveryTrait(3) diff --git a/src/com/homelab/stages/notify.groovy b/src/com/homelab/stages/notify.groovy new file mode 100644 index 0000000..122bc3c --- /dev/null +++ b/src/com/homelab/stages/notify.groovy @@ -0,0 +1,14 @@ +package com.homelab.stages + +// Rewritten for this homelab. The original posted to Homelab's real Slack +// workspace, an internal deployment-tracker API, and Ringmaster (their +// deployment-approval system) — none of which exist here. This just logs +// to the build console, which is all a solo homelab pipeline needs; +// swap in a real notification channel later if you ever want one (e.g. +// a Gitea webhook back to a commit status, or your own Slack if you set +// one up). +def run(Map config) { + stage(stageName('Notify')) { + log.info("Build ${currentBuild.currentResult} for ${config.repo_name} — tag ${env.TAG} — ${env.BUILD_URL}") + } +} diff --git a/src/com/homelab/stages/runHooks.groovy b/src/com/homelab/stages/runHooks.groovy new file mode 100644 index 0000000..6c4660d --- /dev/null +++ b/src/com/homelab/stages/runHooks.groovy @@ -0,0 +1,134 @@ +package com.homelab.stages + +// Simplified from the real devops-lib's vars/runHooks.groovy — same core +// mechanism: repo-declared scripts under hooks. in config.yaml, +// blocking by default with an explicit `blocking: false` opt-out to +// advisory (log + continue), repo-relative path validation (no absolute +// paths, no `..` traversal), interpreter resolution (explicit > +// extension > shebang), python venv + requirements provisioning, a +// timeout per hook. Dropped: the deploy-phase cdHookRunner reuse (we +// don't have a separate deploy-phase repo checkout — everything happens +// in one pipeline) and the Turbo-Turtle callback system (TT_* env vars +// renamed to HOOK_* — same shape, no Homelab-specific meaning attached). +// +// Called as runHooksObj.run(config, 'pre_build') / 'post_build' from +// vars/homelabPipeline.groovy, around the buildDocker stage. +def run(Map config, String phase) { + def hooksBlock = config?.hooks + if (!(hooksBlock instanceof Map)) { + return + } + def hooks = hooksBlock[phase] + if (!(hooks instanceof List) || hooks.isEmpty()) { + return + } + + String repoName = config.repo_name + hooks.eachWithIndex { hook, idx -> + runOneHook(repoName, phase, idx, hook) + } +} + +def runOneHook(String repoName, String phase, int idx, def hook) { + String name = (hook?.name ?: "${phase}-${idx}").toString() + String script = hook?.script?.toString() + String interpreter = hook?.interpreter?.toString() + String requirements = hook?.requirements?.toString() + // Blocking by default; only an explicit `blocking: false` demotes to advisory. + boolean blocking = !(hook?.blocking?.toString() == 'false') + int timeoutSeconds = 600 + if (hook?.timeout_seconds) { + try { timeoutSeconds = hook.timeout_seconds.toString().toInteger() } catch (ignored) { timeoutSeconds = 600 } + } + + if (!script) { + error("runHooks: ${phase}[${idx}] '${name}' has no 'script' path in config.yaml.") + } + assertRepoRelative(script, "${phase}[${idx}] '${name}' script") + if (requirements) { + assertRepoRelative(requirements, "${phase}[${idx}] '${name}' requirements") + } + + stage(stageName("${phase}: ${name}")) { + container('docker-cli') { + dir(repoName) { + if (!fileExists(script)) { + error("runHooks: ${phase} hook '${name}' script not found in repo: ${script}") + } + List hookEnv = [ + "HOOK_PHASE=${phase}", + "HOOK_NAME=${name}", + "HOOK_REPO=${repoName}", + "HOOK_IMAGE_TAG=${env.TAG ?: ''}", + ] + String runCmd = buildRunCommand(script, interpreter, requirements) + log.info("runHooks: executing ${phase} hook '${name}' (${script}), blocking=${blocking}, timeout=${timeoutSeconds}s") + withEnv(hookEnv) { + try { + timeout(time: timeoutSeconds, unit: 'SECONDS') { + sh(script: runCmd) + } + } catch (Exception e) { + if (blocking) { + log.error("runHooks: blocking ${phase} hook '${name}' failed: ${e}") + throw e + } + log.warning("runHooks: advisory ${phase} hook '${name}' failed (non-blocking): ${e}") + currentBuild.description = (currentBuild.description ? currentBuild.description + " | " : "") + "hook(${name}) advisory-failed" + } + } + } + } + } +} + +def buildRunCommand(String script, String interpreter, String requirements) { + String interp = interpreter + if (!interp) { + if (script.endsWith('.py')) { + interp = 'python3' + } else if (script.endsWith('.sh')) { + interp = 'bash' + } + } + + boolean isPython = (interp == 'python3' || interp == 'python' || script.endsWith('.py')) + // docker:27-cli is minimal Alpine — only `sh` is guaranteed present. + // bash/python3 need installing on demand, unlike the real system's + // pod images which already bundle a full toolchain. + String installLine = '' + if (isPython) { + installLine = 'apk add --no-cache python3 py3-pip py3-virtualenv >/dev/null' + } else if (interp == 'bash') { + installLine = 'apk add --no-cache bash >/dev/null' + } + + if (requirements && isPython) { + String py = interp ?: 'python3' + return """ + set -e + ${installLine} + ${py} -m venv .hook_venv + . .hook_venv/bin/activate + pip install --quiet --disable-pip-version-check -r ${requirements} + ${py} ${script} + """.stripIndent().trim() + } + + if (interp) { + return "set -e\n${installLine}\n${interp} ${script}" + } + // No interpreter resolved — rely on the script's shebang. + return "set -e\nchmod +x ${script}\n./${script}" +} + +// Rejects absolute paths and parent-directory traversal so a hook can +// only execute code that lives inside the checked-out repo. +def assertRepoRelative(String p, String what) { + if (p.startsWith('/')) { + error("runHooks: ${what} path '${p}' must be repo-relative, not absolute.") + } + if (p == '..' || p.startsWith('../') || p.contains('/../')) { + error("runHooks: ${what} path '${p}' must not traverse outside the repo ('..').") + } +} diff --git a/src/com/meesho/stages/securityScan.groovy b/src/com/homelab/stages/securityScan.groovy similarity index 97% rename from src/com/meesho/stages/securityScan.groovy rename to src/com/homelab/stages/securityScan.groovy index b29fe8e..b0e731b 100644 --- a/src/com/meesho/stages/securityScan.groovy +++ b/src/com/homelab/stages/securityScan.groovy @@ -1,4 +1,4 @@ -package com.meesho.stages +package com.homelab.stages def run(Map config) { try { diff --git a/src/com/homelab/stages/syncArgoApp.groovy b/src/com/homelab/stages/syncArgoApp.groovy new file mode 100644 index 0000000..55930e1 --- /dev/null +++ b/src/com/homelab/stages/syncArgoApp.groovy @@ -0,0 +1,39 @@ +package com.homelab.stages + +// New stage — the homelab equivalent of devops-lib's real +// refresh_and_sync (deployArgoCD.groovy step 4: `argocd app sync +// --hard-refresh`). Without this, the pipeline stops at the tag-bump +// commit and a human has to remember to click Sync in the ArgoCD UI — +// their real system never leaves that step manual. Uses the ArgoCD REST +// API directly via curl (scoped jenkins-ci token, not the argocd CLI +// binary — avoids adding another container to dind-pod.yaml just for +// this one call) against the server's internal cluster-DNS Service, not +// the ingress — same pod-to-pod reasoning as pushing to Harbor. +// +// ARGOCD_TOKEN comes from the pod env (dind-pod.yaml, ESO-managed secret) +// — not Jenkins' own credential store, staying consistent with the rest +// of this pipeline. It's marked optional there, so if it's genuinely +// empty (bootstrap token not generated yet), fail loudly here with a +// clear message rather than a confusing curl auth error. +// +// Expects in config: +// argo_app_name the Application's metadata.name, e.g. demo-go-app +// argo_server_url e.g. http://argocd-admin-prd-server.argocd.svc.cluster.local +def run(Map config) { + stage(stageName('Sync ArgoCD Application')) { + container('docker-cli') { + if (!env.ARGOCD_TOKEN?.trim()) { + log.error('ARGOCD_TOKEN is empty — the jenkins-ci account token has not been generated yet. See secretstores/argocd-jenkins-ci-token.yaml for the one-time bootstrap steps.') + error('Skipping ArgoCD sync: no token available.') + } + sh """ + apk add --no-cache curl >/dev/null + curl -sf -X POST \\ + -H "Authorization: Bearer \$ARGOCD_TOKEN" \\ + -H "Content-Type: application/json" \\ + -d '{}' \\ + "${config.argo_server_url ?: 'http://argocd-admin-prd-server.argocd.svc.cluster.local'}/api/v1/applications/${config.argo_app_name}/sync" + """ + } + } +} diff --git a/src/com/homelab/stages/updateHelmTag.groovy b/src/com/homelab/stages/updateHelmTag.groovy new file mode 100644 index 0000000..6c36032 --- /dev/null +++ b/src/com/homelab/stages/updateHelmTag.groovy @@ -0,0 +1,43 @@ +package com.homelab.stages + +// New stage — no equivalent this simple existed before. The original's +// version (deployArgoCD.groovy's update_helm_repo, ~900 lines) ran a full +// PR workflow — branch, commit, push, create PR, merge PR, delete branch +// — against Homelab's real GitHub org, driven by a BU/team templating +// engine and canary-enforcement rules. Solo homelab, no reviewer to wait +// on: this just clones, bumps the tag with yq, commits, and pushes +// straight to main. ArgoCD picks up the change on its own next sync +// (manual, same as everything else in this repo — see the sister repo's +// README on sync policy). +// +// Expects in config: +// repo_name the app's repo name — also the first path segment +// under devops-helm-charts/values/ +// service_name second path segment; same as repo_name for a +// single-service repo, different for a monorepo with +// several services sharing one repo +// helm_repo_url e.g. http://gitea.192.168.1.7.nip.io/mukul/devops-helm-charts.git +// image_tag_yq_path yq path to the tag field, e.g. .deployment.image.tag +// gitea_cred Jenkins credential ID for a Gitea push-capable token (default: gitea-ci-credentials) +// +// Values file path is computed, not passed directly: +// devops-helm-charts/values///values.yaml +def run(Map config) { + def valuesFile = "values/${config.repo_name}/${config.service_name}/values.yaml" + stage(stageName('Update Helm chart image tag')) { + withCredentials([usernamePassword(credentialsId: config.gitea_cred ?: 'gitea-ci-credentials', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')]) { + dir('helm-chart-repo') { + deleteDir() + def authedUrl = config.helm_repo_url.replaceFirst('http://', "http://\${GIT_USER}:\${GIT_PASS}@") + sh """ + git clone ${authedUrl} . + yq -i '${config.image_tag_yq_path} = "${env.TAG}"' ${valuesFile} + git config user.email 'jenkins-ci@homelab.local' + git config user.name 'jenkins-ci' + git commit -am 'ci: bump ${config.repo_name}/${config.service_name} image tag to ${env.TAG}' + git push origin main + """ + } + } + } +} diff --git a/src/com/meesho/stages/validateBuTeam.groovy b/src/com/homelab/stages/validateBuTeam.groovy similarity index 86% rename from src/com/meesho/stages/validateBuTeam.groovy rename to src/com/homelab/stages/validateBuTeam.groovy index 6aa34d0..d3f0405 100644 --- a/src/com/meesho/stages/validateBuTeam.groovy +++ b/src/com/homelab/stages/validateBuTeam.groovy @@ -1,6 +1,6 @@ -package com.meesho.stages +package com.homelab.stages -import com.meesho.utilities.buTeamMapping +import com.homelab.utilities.buTeamMapping def run(String bu, String team,String module){ stage("Validate BU and Team"){ diff --git a/src/com/meesho/utilities/addSSHKey.groovy b/src/com/homelab/utilities/addSSHKey.groovy similarity index 96% rename from src/com/meesho/utilities/addSSHKey.groovy rename to src/com/homelab/utilities/addSSHKey.groovy index d92da4f..7464525 100644 --- a/src/com/meesho/utilities/addSSHKey.groovy +++ b/src/com/homelab/utilities/addSSHKey.groovy @@ -1,4 +1,4 @@ -package com.meesho.utilities +package com.homelab.utilities def create() { withCredentials([file(credentialsId: 'ssh-private-key', variable: 'FILE')]) { diff --git a/src/com/meesho/utilities/buTeamMapping.groovy b/src/com/homelab/utilities/buTeamMapping.groovy similarity index 99% rename from src/com/meesho/utilities/buTeamMapping.groovy rename to src/com/homelab/utilities/buTeamMapping.groovy index 3eae348..d4a0fce 100644 --- a/src/com/meesho/utilities/buTeamMapping.groovy +++ b/src/com/homelab/utilities/buTeamMapping.groovy @@ -2,7 +2,7 @@ Purpose: Utility function to return BU and their respective teams Author: Avinash kumar Lodhi */ -package com.meesho.utilities +package com.homelab.utilities def validate(String bu, String team) { def bu_team_map = ['supply':['supplier-ads', 'supplier-ads-frontend', 'experience', 'fulfilment', 'fulfilment-frontend','financial-services', 'cataloging', 'cataloging-frontend', 'payout', 'payout-frontend', 'supplier-acquisition-activation', 'supplier-service', 'returns', 'supply-shared', 'display-ads', 'offers','transact', 'supplier-live-commerce'], diff --git a/src/com/meesho/utilities/constructParam.groovy b/src/com/homelab/utilities/constructParam.groovy similarity index 90% rename from src/com/meesho/utilities/constructParam.groovy rename to src/com/homelab/utilities/constructParam.groovy index c467d49..7c13e94 100644 --- a/src/com/meesho/utilities/constructParam.groovy +++ b/src/com/homelab/utilities/constructParam.groovy @@ -1,10 +1,10 @@ -package com.meesho.utilities +package com.homelab.utilities def getWhitelistedRepos(fileName){ dir('whitelist'){ git( - url: "https://github.com/Meesho/whitelists.git", + url: "https://github.com/Homelab/whitelists.git", branch: "main", credentialsId: 'cicd-github-app', )} @@ -15,7 +15,7 @@ def getWhitelistedRepos(fileName){ def getWhitelistedDeployable(fileName, keyName){ dir('whitelist'){ git( - url: "https://github.com/Meesho/whitelists.git", + url: "https://github.com/Homelab/whitelists.git", branch: "main", credentialsId: 'cicd-github-app', )} @@ -151,7 +151,7 @@ def run(Map config) { config.putAll(envrionment_config) } - env.GITHUB_CRED = 'svc-devops-meesho' + env.GITHUB_CRED = 'svc-devops-homelab' env.cicd_environment = environment_map[branch_name] env.helm_repo_name = 'devops-helm-charts' env.argo_repo_name = 'devops-argo-config' @@ -160,9 +160,9 @@ def run(Map config) { if (env.CLOUD_PROVIDER == 'AWS') { def prodAccountID = '847438129436' def prodRegion = 'ap-southeast-1' - def prodObjBucket = 'meesho-prod-artifacts' + def prodObjBucket = 'homelab-prod-artifacts' def devAccountID = '766380763301' - def devObjBucket = 'meesho-stg-artifacts' + def devObjBucket = 'homelab-stg-artifacts' def devRegion = 'ap-south-1' def accountDetails = [ 'prd': [ @@ -197,23 +197,23 @@ def run(Map config) { echo "${env.accountID}.dkr.ecr.${env.region}.amazonaws.com" } else if (env.CLOUD_PROVIDER == 'GCP') { - def prodVaultURL = 'https://vault-prd.meeshogcp.in' + def prodVaultURL = 'https://vault-prd.homelabgcp.in' def prodVaultToken = 'vault-prd-token' - def prodSonarURL = 'https://sonarqube-prd.meeshogcp.in' + def prodSonarURL = 'https://sonarqube-prd.homelabgcp.in' def prodSonarToken = 'sonar-token-prod' def prodSonarEnv = 'sonarqube-test' - def prodGoProxyUrl = 'https://athens-prd.meeshogcp.in' + def prodGoProxyUrl = 'https://athens-prd.homelabgcp.in' def prdDockerHost = 'dind-prd-svc' def preProdDockerHost = 'dind-int-svc' - def prodGCPProject = "meesho-${config.bu}-prd-0622" - def preprodGCPProject = "meesho-shared-int-0525" - def devVaultURL = 'https://vault-dev.meeshogcp.in' + def prodGCPProject = "homelab-${config.bu}-prd-0622" + def preprodGCPProject = "homelab-shared-int-0525" + def devVaultURL = 'https://vault-dev.homelabgcp.in' def devVaultToken = 'vault-dev-token' - def devSonarURL = "https://sonarqube-${config.bu}-dev.meeshogcp.in" + def devSonarURL = "https://sonarqube-${config.bu}-dev.homelabgcp.in" def devSonarToken = "sonar-token-${config.bu}-dev" def devSonarEnv = "sonar-${config.bu}-dev" - def devGoProxyUrl = 'https://athens-dev.meeshogcp.in' - def devGCPProject = "meesho-${config.bu}-dev-0622" + def devGoProxyUrl = 'https://athens-dev.homelabgcp.in' + def devGCPProject = "homelab-${config.bu}-dev-0622" def devDockerHost = 'dind-dev-new-svc.jenkins-new.svc.cluster.local' def toolchainDockerHost = 'toolchain-dind-dev-svc.jenkins-toolchain.svc.cluster.local' def accountDetails = [ @@ -263,14 +263,14 @@ def run(Map config) { ] env.GCPProject = accountDetails[env.cicd_environment]['GCPProject'] env.GCPLBProject = accountDetails[env.cicd_environment]['GCPLBProject'] - env.registry = 'asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622' + env.registry = 'asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622' if (env.INFRA_ENV == 'toolchain') { - env.registry = 'asia-southeast1-docker.pkg.dev/meesho-central-dev-0622/toolchain' + env.registry = 'asia-southeast1-docker.pkg.dev/homelab-central-dev-0622/toolchain' } - env.buildRegistry = 'asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/admin' + env.buildRegistry = 'asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/admin' env.helmChartsPath = env.cicd_environment == 'prd' ? 'values_v3' : 'values_v2' env.defaultHelmChartVersion = '2.0.0' - env.objBucket = "gcs-infr-dvps-meesho-artifacts-${env.cicd_environment}" + env.objBucket = "gcs-infr-dvps-homelab-artifacts-${env.cicd_environment}" env.vaultURL = accountDetails[env.cicd_environment]['vaultURL'] env.vaultToken = accountDetails[env.cicd_environment]['vaultToken'] env.sonarURL = accountDetails[env.cicd_environment]['sonarURL'] @@ -293,8 +293,8 @@ def perDeploymentVars(Map value_binding) { if (env.CLOUD_PROVIDER == 'AWS') { def inClusterName = 'https://kubernetes.default.svc' - def prodArgoURL = 'prod-ops-argocd.meesho.com' - def devArgoURL = 'stg-dev-argocd.meeshotest.in' + def prodArgoURL = 'prod-ops-argocd.homelab.com' + def devArgoURL = 'stg-dev-argocd.homelabtest.in' def prodK8sCluster = [ 'supply': 'https://211689C65F4496AAA76FE19B29E24B6E.yl4.ap-southeast-1.eks.amazonaws.com', 'demand': 'https://9059D138B6277A0EA592BA7F4B680CEC.gr7.ap-southeast-1.eks.amazonaws.com', @@ -341,11 +341,11 @@ def perDeploymentVars(Map value_binding) { env.argoAppNS = 'argocd' } else if (env.CLOUD_PROVIDER == 'GCP') { - def prodArgoURL = "argocd-${env.BU}-prd.meeshogcp.in" + def prodArgoURL = "argocd-${env.BU}-prd.homelabgcp.in" def prodArgoCreds = "argocd-${env.BU}-prd-creds" - def preprodArgoURL = "argocd-shared-int.meeshogcp.in" + def preprodArgoURL = "argocd-shared-int.homelabgcp.in" def preprodArgoCreds = "argocd-shared-int-creds" - def devArgoURL = 'argocd-dev.meeshogcp.in' + def devArgoURL = 'argocd-dev.homelabgcp.in' def devArgoCreds = 'argocd-dev-creds' def accountDetails = [ 'prd': [ diff --git a/src/com/homelab/utilities/constructTemplate.groovy b/src/com/homelab/utilities/constructTemplate.groovy new file mode 100644 index 0000000..42519c3 --- /dev/null +++ b/src/com/homelab/utilities/constructTemplate.groovy @@ -0,0 +1,26 @@ +package com.homelab.utilities + +// Ported from the real devops-lib's constructTemplate.groovy — same +// SimpleTemplateEngine mechanism (${...} interpolation, <% %> control +// flow), same @NonCPS requirement (the engine is a non-serialisable Java +// object; calling this across a `parallel` boundary would break). Dropped +// the Homelab-specific `add_file`/PBAC resolution — this homelab has no +// equivalent convention yet; add it back here if that's ever needed. +def run(Map binding, String text) { + return _construct(binding, text) +} + +def renderTemplate(Map binding, String templateFile, String fileName) { + def template = libraryResource 'com/homelab/' + templateFile + def renderedTemplate = run(binding, template.toString()) + writeFile file: fileName, text: renderedTemplate +} + +@NonCPS +def _construct(Map binding, String text) { + binding = new HashMap(binding) + def engine = new groovy.text.SimpleTemplateEngine() + def template = engine.createTemplate(text).make(binding) + engine = null + return template.toString() +} diff --git a/src/com/meesho/utilities/dockerUtilities.groovy b/src/com/homelab/utilities/dockerUtilities.groovy similarity index 98% rename from src/com/meesho/utilities/dockerUtilities.groovy rename to src/com/homelab/utilities/dockerUtilities.groovy index 05018af..89ce40b 100644 --- a/src/com/meesho/utilities/dockerUtilities.groovy +++ b/src/com/homelab/utilities/dockerUtilities.groovy @@ -1,4 +1,4 @@ -package com.meesho.utilities +package com.homelab.utilities def retryDockerPush(String cmd) { int maxAttempts = 5 diff --git a/src/com/meesho/utilities/getDockerParams.groovy b/src/com/homelab/utilities/getDockerParams.groovy similarity index 98% rename from src/com/meesho/utilities/getDockerParams.groovy rename to src/com/homelab/utilities/getDockerParams.groovy index 3893640..b602bd5 100644 --- a/src/com/meesho/utilities/getDockerParams.groovy +++ b/src/com/homelab/utilities/getDockerParams.groovy @@ -1,4 +1,4 @@ -package com.meesho.utilities +package com.homelab.utilities def getCommitid(String repo_name) { dir(repo_name) { diff --git a/src/com/meesho/utilities/getYamlParameter.groovy b/src/com/homelab/utilities/getYamlParameter.groovy similarity index 92% rename from src/com/meesho/utilities/getYamlParameter.groovy rename to src/com/homelab/utilities/getYamlParameter.groovy index eb116cf..6cb06c9 100644 --- a/src/com/meesho/utilities/getYamlParameter.groovy +++ b/src/com/homelab/utilities/getYamlParameter.groovy @@ -1,4 +1,4 @@ -package com.meesho.utilities +package com.homelab.utilities def getParam(String wd, String fileName = 'config.yaml') { dir(wd) { diff --git a/src/com/meesho/utilities/gitActions.groovy b/src/com/homelab/utilities/gitActions.groovy similarity index 96% rename from src/com/meesho/utilities/gitActions.groovy rename to src/com/homelab/utilities/gitActions.groovy index 014e641..d41c406 100644 --- a/src/com/meesho/utilities/gitActions.groovy +++ b/src/com/homelab/utilities/gitActions.groovy @@ -1,4 +1,4 @@ -package com.meesho.utilities +package com.homelab.utilities def clone(String path, String repo_name, String branch_name) { log.info("Cloning repo - ${repo_name}, branch - ${branch_name} in path - ${path}") @@ -12,10 +12,10 @@ def clone(String path, String repo_name, String branch_name) { try { withCredentials([gitUsernamePassword(credentialsId: "${env.GITHUB_CRED}", gitToolName: 'git-tool')]) { if (branch_name) { - sh "git clone -b ${branch_name} https://github.com/Meesho/${repo_name}.git" + sh "git clone -b ${branch_name} https://github.com/Homelab/${repo_name}.git" } else { - sh "git clone https://github.com/Meesho/${repo_name}.git" + sh "git clone https://github.com/Homelab/${repo_name}.git" } } } @@ -79,8 +79,8 @@ def createTag(path, git_tag, tag_message) { def codeCommit(String path, String branch_name, String commit_message) { log.info("Commiting code with message - ${commit_message} in git, in path - ${path}") def global_arg = '--global' - def gitName = 'svc-devops-meesho' - def gitEmail = 'devops@meesho.com' + def gitName = 'svc-devops-homelab' + def gitEmail = 'devops@homelab.com' def gitEnv = [ "GIT_AUTHOR_NAME=${gitName}", "GIT_AUTHOR_EMAIL=${gitEmail}", @@ -163,7 +163,7 @@ def createPR(String app_name, String repo_name, String base_branch, String targe [maskValue: true, name: 'Authorization', value: 'Bearer ' + token] ], requestBody: body, - url: "https://api.github.com/repos/Meesho/${repo_name}/pulls", + url: "https://api.github.com/repos/Homelab/${repo_name}/pulls", validResponseCodes: '201', timeout: 10 def create_pr_json = readJSON(text: create_pr.content) @@ -212,13 +212,13 @@ def mergePR(String repo_name, String pr_num, String target_branch) { [name: 'Accept', value: 'application/vnd.github+json'], [maskValue: true, name: 'Authorization', value: 'Bearer ' + token] ], - url: "https://api.github.com/repos/Meesho/${repo_name}/pulls/${pr_num}/merge", + url: "https://api.github.com/repos/Homelab/${repo_name}/pulls/${pr_num}/merge", validResponseCodes: '200', timeout: 10 def merge_pr_json = readJSON(text: merge_pr.content) if ( merge_pr_json.message.contains('not mergeable') ) { - env.msg += "\n\nFAILED -\n Unable to merge PR - ${pr_num}. PR URL - https://github.com/Meesho/${repo_name}/pulls/${pr_num}. ${merge_pr_json.message}" + env.msg += "\n\nFAILED -\n Unable to merge PR - ${pr_num}. PR URL - https://github.com/Homelab/${repo_name}/pulls/${pr_num}. ${merge_pr_json.message}" log.error("${env.msg}") error("${env.msg}") } diff --git a/src/com/meesho/utilities/nodePoolSelection.groovy b/src/com/homelab/utilities/nodePoolSelection.groovy similarity index 99% rename from src/com/meesho/utilities/nodePoolSelection.groovy rename to src/com/homelab/utilities/nodePoolSelection.groovy index ac8d4db..d881d46 100644 --- a/src/com/meesho/utilities/nodePoolSelection.groovy +++ b/src/com/homelab/utilities/nodePoolSelection.groovy @@ -1,4 +1,4 @@ -package com.meesho.utilities +package com.homelab.utilities def run(String memory_request, String cpu_request, String priority_v2) { echo 'Code to select node pool based on environment' diff --git a/src/com/meesho/stages/buildDocker.groovy b/src/com/meesho/stages/buildDocker.groovy deleted file mode 100644 index d068865..0000000 --- a/src/com/meesho/stages/buildDocker.groovy +++ /dev/null @@ -1,68 +0,0 @@ -package com.meesho.stages - -import com.meesho.stages.deployArgoCD -import com.meesho.stages.buildObjHelper -import com.meesho.utilities.buTeamMapping - -def run(Map config) { - def btObj = new buTeamMapping() - def helperObj = new buildObjHelper() - def buildObj = helperObj.run(config.dockerBuildVersion) - def (tag , deployArgo) = buildObj.buildDckr(config) - release(config, tag, deployArgo) -} - -def release(Map config, String tag, boolean deployArgo) { - //TODO: move params to run function and move argoCD call there as well. - def btObj = new buTeamMapping() - def repo_name = config.repo_name - def branch_name = "${env.BRANCH_NAME}" - def team = btObj.get_team_initials(config.team) - env.TAG = tag - - log.info("tag is ${tag}") - - def bu = btObj.get_bu_initials(config.bu) - def notify_channel = config.notify_channel && config.notify_channel != '' ? config.notify_channel : 'canary-status' - validate('bu', bu, config.bu) - validate('team', team, config.team) - def build_user = currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId() - env.deployArgo = deployArgo - // Calling Ringmaster - if (build_user != "ringmaster-bot" && build_user!="turbo-turtle" && build_user != "toolchain-jenkins"){ - if (env.cicd_environment == 'ftr') { - log.warning("**********!!!!!! Deployments in '${env.cicd_environment}' env are not supported !!!!!!**********") - log.info("****** To deploy in Staging, Please merge the changes to your 'develop'/'development' branch and deploy ******") - return - } - if (deployArgo) { - def argoCd_obj = new deployArgoCD() - def deployment_order = config.deployment_order - def dockerBuildVersion = config.dockerBuildVersion - argoCd_obj.run(repo_name, deployment_order, tag, team, dockerBuildVersion, notify_channel) - } else { - log.info("Skipping ArgoCD deployment for ${repo_name}") - } - - if (config.distribution_id) { - stage(stageName('Refreshing CDN file')) { - def folder_name = config.chunk_base_path ?: repo_name.split('_')[-1] - if (env.CLOUD_PROVIDER == 'AWS') { - sh(script:"aws cloudfront create-invalidation --distribution-id ${config.distribution_id} --paths \"/${folder_name}/remoteEntry.js\"") - } - else if (env.CLOUD_PROVIDER == 'GCP') { - // echo "Skipping - CDN Invalidation" - sh(script:"gcloud config set project ${env.GCPLBProject};gcloud compute url-maps invalidate-cdn-cache '${config.distribution_id}' --path \"/${folder_name}/remoteEntry.js\" --project='${env.GCPLBProject}' --async") - } - } - } - } -} - -def validate(String name, String value, String printValue) { - if (value == null) { - log.error("Incorrect ${name} name ${printValue}") - currentBuild.result = env.FAILURE - return - } -} diff --git a/src/com/meesho/stages/checkOut.groovy b/src/com/meesho/stages/checkOut.groovy deleted file mode 100644 index 5c5d0f3..0000000 --- a/src/com/meesho/stages/checkOut.groovy +++ /dev/null @@ -1,45 +0,0 @@ -package com.meesho.stages - -def run(Map param) { - try { - stage(stageName('Checkout from git')) { - dir("${param.repo_name}") { - checkout scm - if (fileExists('.gitmodules')) { - log.info('Repository has submodules - running git submodule init and update --recursive') - def credId = env.GITHUB_CRED?.trim() - if (!credId || credId == 'null') credId = 'svc-devops-meesho' - withCredentials([gitUsernamePassword(credentialsId: credId, gitToolName: 'git-tool')]) { - sh 'git submodule init && git submodule update --recursive' - } - } - } - } - } - catch( Exception e) { - env.msg = 'Error cloning the job. Error: ' + e.toString() - env.error_msg_to_db = 'Error cloning the job' - log.error(env.msg) - currentBuild.result = env.FAILURE - throw e - } -} - -def chekoutSubmodule(String repo_name) { - try { - def credId = env.GITHUB_CRED?.trim() - if (!credId || credId == 'null') credId = 'svc-devops-meesho' - dir(repo_name) { - withCredentials([gitUsernamePassword(credentialsId: credId, gitToolName: 'git-tool')]) { - sh(script:'git submodule init && git submodule update && git submodule update --recursive --remote') - } - } - } - catch(Exception e) { - env.msg = 'Error submodule checkout' - env.error_msg_to_db = env.msg - log.error(env.msg) - currentBuild.result = env.FAILURE - throw e - } -} diff --git a/src/com/meesho/stages/notify.groovy b/src/com/meesho/stages/notify.groovy deleted file mode 100644 index 88edf36..0000000 --- a/src/com/meesho/stages/notify.groovy +++ /dev/null @@ -1,206 +0,0 @@ -package com.meesho.stages - -import hudson.Util -import com.meesho.utilities.getDockerParams -import com.meesho.stages.deployRingmaster -import com.meesho.utilities.buTeamMapping - -def run(Map config) { - def maintainer = config.maintainer - def skip_notify = config.skip_notify ?: false - def notify_channel = config.notify_channel && config.notify_channel != '' ? config.notify_channel : 'ci-cd-status' - def build_user = currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId() - def COLOR_MAP = ['SUCCESS':'good', 'FAILURE':'danger'] - def build_duration = Util.getTimeSpanString(System.currentTimeMillis() - currentBuild.startTimeInMillis) - stage(stageName('Sending notification')) { - if (env.INFRA_ENV == 'toolchain') { - log.info("Toolchain environment detected. Sending signal...") - def dkrobj = new getDockerParams() - def commit_id=dkrobj.getCommitid(config.repo_name) - log.info("Toolchain environment detected. Sending signal...") - def btObj = new buTeamMapping() - def team_initial = btObj.get_team_initials(config.team) - def isNodeBuild = (config.dockerBuildVersion?.toString()?.toLowerCase()?.startsWith('node-')) - def image_path="${env.cicd_environment}/${team_initial}/${config.repo_name}".toLowerCase() - if (env.TOOLCHAIN_ENV && isNodeBuild) { - image_path = "${env.cicd_environment}/${env.TOOLCHAIN_ENV}/${team_initial}/${config.repo_name}".toLowerCase() - log.info("Toolchain: Node build detected, using TOOLCHAIN_ENV-aware image_path: ${image_path}") - } - else { - image_path = "${env.cicd_environment}/${team_initial}/${config.repo_name}".toLowerCase() - log.info("Toolchain: using default image_path (no TOOLCHAIN_ENV segment): ${image_path}") - } - def modules_to_notify = config.modules ?: "" - def imageList = [] - if (modules_to_notify != "") { - imageList = modules_to_notify.collect { module -> - def moduleName = (module instanceof Map) ? module.keySet()[0] : module.toString() - "${env.registry}/${image_path}/${moduleName}:${env.TAG}" - } - } else { - imageList = ["${env.registry}/${image_path}:${env.TAG}"] - } - def payload = [ - "repo_name": config.repo_name, - "build_number": env.BUILD_NUMBER, - "build_status": currentBuild.currentResult, - "image_path": image_path, - "image_tag": env.TAG, - "commit_id": commit_id, - "imageList": imageList.join(',') - ] - - def jsonPayload = writeJSON(returnText: true, json: payload) - - try { - sh """ - curl -k --insecure -X POST -H "Content-Type: application/json" \ - -d '${jsonPayload}' \ - http://172.23.72.116:5002/api/v1/deploy/build-callback - """ - log.info("Toolchain signal sent successfully.") - } catch (Exception e) { - log.error("Failed to send Toolchain signal: ${e.toString()}") - } - return - } - if (build_user == "ringmaster-bot" || build_user == "turbo-turtle") { - def ringmaster_obj = new deployRingmaster() - def btObj = new buTeamMapping() - def team = btObj.get_team_initials(config.team) - ringmaster_obj.run(config.repo_name, config.deployment_order, env.TAG, team, config.dockerBuildVersion, notify_channel) - if(env.cicd_environment == "prd"){ - slackSend color:COLOR_MAP[currentBuild.currentResult], channel:notify_channel, message: "[*${currentBuild.currentResult}*]\n Repo Name - ${config.repo_name}\n maintainer - @${maintainer}\n Time Taken - ${build_duration}\n Build logs - <${BUILD_URL}/console|Open URL>\n TAG for CD - ```${env.TAG}``` Job Message - ```${env.msg}```\n Deploy Applications - " - } - skip_notify = true - } - if (skip_notify.toBoolean()) { - echo "${config.skip_notify} ${skip_notify}" - log.info('Skipping - Slack Notification.') - } - else { - slackSend color:COLOR_MAP[currentBuild.currentResult], channel:notify_channel, message: "[*${currentBuild.currentResult}*]\n Job Name - <${JOB_URL}|${JOB_NAME}>\n Build Number - <${BUILD_URL}|#${BUILD_NUMBER}>\n Started by - @${maintainer}\n Time Taken - ${build_duration}\n Console Output - <${BUILD_URL}/console|Open URL>\n TAG for CD - ```${env.TAG}``` Job Message - ```${env.msg}```" - } - - if (env.BRANCH_NAME ==~ /(gcp-main|main|gcp-master|master|farmiso-main)/) { - postTrackingApi(config) - if (env.SERVICES != null && (build_user != "ringmaster-bot" || build_user != "turbo-turtle")) { - log.info('Updating Ringmaster deployment history db') - postTrackingRingmasterApi(config) - } - } - else { - log.info('Skipping - Updating in Deployment Tracker.') - } - } -} - -def postTrackingRingmasterApi(Map config){ - log.info('Updating Deployment Details in Ringmaster DB') - final String baseUrl - switch (env.cicd_environment) { - case 'prd': - case 'int': - baseUrl = 'https://ringmaster-api.admin.meeshogcp.in/api/v1/key/update/deployment-history' - break - default: - baseUrl = 'https://ringmaster-api.admin.meeshogcp.in/api/v1/key/update/deployment-history' - } - def working_env = "gcp_${env.cicd_environment}" - final String url = "${baseUrl}?workingEnv=${working_env}" - final String jsonData = getRingmasterJsonData(config) - callRingmasterApi(url, jsonData) -} - -def callRingmasterApi(String url, String jsonData) { - try { - withCredentials([usernamePassword(credentialsId: "ringmaster-token", usernameVariable: 'user', passwordVariable: 'token')]) { - def response = sh( - script: """ - curl -s -X POST \ - -H "Content-Type: application/json" \ - -H "Authorization: $token" \ - -d '${jsonData}' \ - ${url} - """, - returnStdout: true - ).trim() - - log.info("API call response: ${response}") - } - } catch (Exception e) { - log.error("API call failed: ${e.message}") - } -} - -def getRingmasterJsonData(Map config) { - def dkrobj = new getDockerParams() - def jsonMap = [:] - - jsonMap['repository'] = config.repo_name - jsonMap['team'] = config.team - jsonMap['link'] = env.BUILD_URL - jsonMap['cd_job'] = env.JOB_NAME - jsonMap['cd_id'] = env.BUILD_NUMBER - jsonMap['initiator'] = currentBuild.rawBuild.getCause(Cause.UserIdCause)?.getUserId() - jsonMap['tag'] = env.TAG - jsonMap['commit_id'] = dkrobj.getCommitid(config.repo_name) - jsonMap['services'] = env.SERVICES ? env.SERVICES.tokenize(',[] ') : [] - jsonMap['status'] = currentBuild.currentResult == 'FAILURE' ? 'FAIL' : currentBuild.currentResult - jsonMap['error_msg'] = env.error_msg_to_db - jsonMap['start_time'] = env.deploymentStartTime - jsonMap['end_time'] = env.deploymentEndTime - jsonMap['working_env'] = "gcp_${env.cicd_environment}" - - def jsonString = writeJSON(returnText: true, json: jsonMap) - return jsonString -} - -def postTrackingApi(Map config) { - final String host = '' - if (env.CLOUD_PROVIDER == 'AWS') { - host = 'http://deployment-tracker.meeshoint.in' - } - else if (env.CLOUD_PROVIDER == 'GCP') { - host = 'http://deployment-tracker.prd.meesho.int' - } - final String path = '/api/1.0/deployment-tracker/jenkins/create' - final String url = "${host}${path}" - final String header = 'Content-Type: application/json' - final String jsonData = getJsonData(config) - - try { - echo "Deployment Tracker URL - ${url}" - final def(String response, String code) = sh(returnStdout: true, script: "curl -s -X POST -H '$header' -w '\\n%{response_code}' $url -d '$jsonData'").trim().tokenize('\n') - log.info("HTTP response status code : ${code}") - if (code != '200') { - log.error("API call failed with error code - ${code}") - } - } - catch ( Exception e) { - log.error('API call failed') - } -} - -def getJsonData(Map config) { - def dkrobj = new getDockerParams() - def build_status_map = ["FAILURE":"FAIL", "SUCCESS":"SUCCESS", "UNSTABLE":"SUCCESS"] - def jsonMap = [:] - jsonMap['repository'] = config.repo_name - jsonMap['team'] = config.team - jsonMap['link'] = env.BUILD_URL - jsonMap['cd_job'] = env.JOB_NAME - jsonMap['cd_id'] = env.BUILD_NUMBER - jsonMap['initiator'] = currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId() - jsonMap['tag'] = env.TAG - jsonMap['commit_id'] = dkrobj.getCommitid(config.repo_name) - jsonMap['services'] = env.SERVICES ? env.SERVICES.tokenize(',[] ') : null - jsonMap['status'] = currentBuild.currentResult == env.FAILURE ? 'FAIL' : currentBuild.currentResult - jsonMap['error_msg'] = env.error_msg_to_db - - def jsonString = writeJSON returnText: true, json: jsonMap - return jsonString -} - - - diff --git a/src/com/meesho/utilities/constructTemplate.groovy b/src/com/meesho/utilities/constructTemplate.groovy deleted file mode 100644 index 1a5ec05..0000000 --- a/src/com/meesho/utilities/constructTemplate.groovy +++ /dev/null @@ -1,51 +0,0 @@ -package com.meesho.utilities - -def run(Map binding, String text) { - return _construct(binding, text) -} - -def renderTemplate(Map binding, String templateFile, String fileName) { - def template = libraryResource 'com/meesho/' + templateFile - // Generic add_file support (language-agnostic): user repos declare files to bake - // into the image under `add_file` in config.yaml -- either a single {path, target} - // mapping or a list of them. renderTemplate always runs inside dir(repo_name), so - // config.yaml resolves to the repo's config. The Dockerfile templates COPY each entry - // into the image. Set for every render so the `add_files.each { ... }` guard never - // hits a missing binding var. This is the one language-agnostic convention for - // mounting extra files (e.g. the ab-client SDK's configs/abacus_experiments.yml -> - // /opt/config/abacus_experiments.yml). - binding['add_files'] = resolveAddFiles() - def renderedTemplate = run(binding, template.toString()) - writeFile file:fileName, text: renderedTemplate -} - -// resolveAddFiles reads config.yaml (if present) and normalises the optional `add_file` -// list into a list of [path, target] maps. `add_file` is a list of {path, target} -// entries; each entry's target defaults to /opt/target when omitted; entries without a -// path are skipped. A non-list add_file is ignored. -def resolveAddFiles() { - if (!fileExists('config.yaml')) { - return [] - } - def cfg = readYaml file: 'config.yaml' - def entries = cfg?.add_file - if (!(entries instanceof List)) { - return [] - } - def result = [] - entries.each { entry -> - if (entry?.path) { - result.add([path: entry.path, target: entry.target ?: '/opt/target']) - } - } - return result -} - -@NonCPS -def _construct(Map binding, String text) { - binding = new HashMap(binding) - def engine = new groovy.text.SimpleTemplateEngine() - def template = engine.createTemplate(text).make(binding) - engine = null - return template.toString() -} diff --git a/vars/buildDockerGroovyGke.groovy b/vars/buildDockerGroovyGke.groovy index 314eb67..4a077ca 100644 --- a/vars/buildDockerGroovyGke.groovy +++ b/vars/buildDockerGroovyGke.groovy @@ -1,4 +1,4 @@ -package com.meesho.stages +package com.homelab.stages def run(Map config){ stage('Build docker image'){ @@ -41,13 +41,13 @@ def getCommitid(){ def registry(String buildenv){ switch(env) { case "prod": - return 'asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/prod/' + return 'asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/prod/' break; case "dev": - return 'asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622/dev/' + return 'asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622/dev/' break; default: - return 'asia-southeast1-docker.pkg.dev/meesho-devops-admin-0622' + return 'asia-southeast1-docker.pkg.dev/homelab-devops-admin-0622' } } @@ -148,12 +148,12 @@ def release(Map config){ def getDockerfile(String dockerBuildVersion, String repo_name, String version, String module, String doBuild) { if (dockerBuildVersion) { if(dockerBuildVersion == "maven-3.3-jdk-8"){ - def scriptcontents = libraryResource "org/meesho/templates/${dockerBuildVersion}.sh" + def scriptcontents = libraryResource "org/homelab/templates/${dockerBuildVersion}.sh" writeFile file: "${dockerBuildVersion}.sh", text: scriptcontents sh "chmod a+x ./${dockerBuildVersion}.sh;./${dockerBuildVersion}.sh ${module} ${version} ${doBuild} ${repo_name}" return "-f Dockerfile-${module} ." }else if(dockerBuildVersion == "node-12.22"){ - def scriptcontents = libraryResource "org/meesho/templates/${dockerBuildVersion}.sh" + def scriptcontents = libraryResource "org/homelab/templates/${dockerBuildVersion}.sh" writeFile file: "${dockerBuildVersion}.sh", text: scriptcontents sh "chmod a+x ./${dockerBuildVersion}.sh;./${dockerBuildVersion}.sh ${module}" return "-f Dockerfile-${module} ." diff --git a/vars/buildPipeline.groovy b/vars/buildPipeline.groovy index 27cf3bc..e9bc318 100644 --- a/vars/buildPipeline.groovy +++ b/vars/buildPipeline.groovy @@ -1,9 +1,9 @@ -import com.meesho.stages.checkOut -import com.meesho.stages.buildObjHelper -import com.meesho.stages.notify -import com.meesho.stages.securityScan -import com.meesho.stages.automationTest -import com.meesho.utilities.constructParam +import com.homelab.stages.checkOut +import com.homelab.stages.buildObjHelper +import com.homelab.stages.notify +import com.homelab.stages.securityScan +import com.homelab.stages.automationTest +import com.homelab.utilities.constructParam def call(Map param) { def constructParam = new constructParam() diff --git a/vars/cdHookRunner.groovy b/vars/cdHookRunner.groovy index 5c2e037..e8540fa 100644 --- a/vars/cdHookRunner.groovy +++ b/vars/cdHookRunner.groovy @@ -25,7 +25,7 @@ def call(Map jobParams = [:]) { String runID = param('TT_RUN_ID', jobParams) if (!repoUrl && repoName) { - repoUrl = "https://github.com/Meesho/${repoName}" + repoUrl = "https://github.com/Homelab/${repoName}" } // TT_WORKFLOW_ID / TT_RUN_ID are required: the completion callback correlates // to the waiting Temporal run by them. If either is missing (e.g. incomplete @@ -37,7 +37,7 @@ def call(Map jobParams = [:]) { // Make env available to stageName / the hook context. env.cicd_environment = ttEnv - String podyaml = "org/meesho/${env.INFRA_ENV ?: 'prd'}-pod.yaml" + String podyaml = "org/homelab/${env.INFRA_ENV ?: 'prd'}-pod.yaml" podTemplate(yaml: libraryResource(podyaml)) { node(POD_LABEL) { container('devops-tools') { @@ -50,7 +50,7 @@ def call(Map jobParams = [:]) { checkout([ $class: 'GitSCM', branches: [[name: commit ?: "*/${branch}"]], - userRemoteConfigs: [[url: repoUrl, credentialsId: 'svc-devops-meesho']], + userRemoteConfigs: [[url: repoUrl, credentialsId: 'svc-devops-homelab']], extensions: [[$class: 'CloneOption', shallow: false, noTags: false]], ]) } @@ -123,10 +123,10 @@ def postCdHookCallback(String repoName, String ttEnv, String phase, boolean succ switch (ttEnv) { case 'prd': case 'int': - baseUrl = 'http://turbo-turtle.meeshogcp.in' + baseUrl = 'http://turbo-turtle.homelabgcp.in' break default: - baseUrl = 'http://turbo-turtle.admin.meeshogcp.in' + baseUrl = 'http://turbo-turtle.admin.homelabgcp.in' } Map payload = [ repo_name : repoName, diff --git a/vars/cloudFunctionCICD.groovy b/vars/cloudFunctionCICD.groovy index d830fa9..d69f187 100644 --- a/vars/cloudFunctionCICD.groovy +++ b/vars/cloudFunctionCICD.groovy @@ -7,7 +7,7 @@ pipeline { GITHUB_CRED = 'cicd-github-app' } - podTemplate(yaml: libraryResource('org/meesho/pod-cloud-function.yaml')) { + podTemplate(yaml: libraryResource('org/homelab/pod-cloud-function.yaml')) { node(POD_LABEL) { container('devops-tools') { cloudFunctionCICDFlow() diff --git a/vars/createEKSconfigs.groovy b/vars/createEKSconfigs.groovy index d0c92a8..7ec9244 100644 --- a/vars/createEKSconfigs.groovy +++ b/vars/createEKSconfigs.groovy @@ -1,13 +1,13 @@ -import com.meesho.stages.helmGenerator -import com.meesho.stages.validateBuTeam +import com.homelab.stages.helmGenerator +import com.homelab.stages.validateBuTeam def call(Map params) { - podTemplate(yaml: libraryResource("org/meesho/${env.INFRA_ENV}-pod.yaml")) { + podTemplate(yaml: libraryResource("org/homelab/${env.INFRA_ENV}-pod.yaml")) { node(POD_LABEL) { container('devops-tools') { timestamps { ansiColor('xterm') { - env.GITHUB_CRED = 'svc-devops-meesho' + env.GITHUB_CRED = 'svc-devops-homelab' // Initialize objects def validateObj = new validateBuTeam() def hemlGenObj = new helmGenerator() diff --git a/vars/eksCICD.groovy b/vars/eksCICD.groovy index 13d9272..dff115b 100644 --- a/vars/eksCICD.groovy +++ b/vars/eksCICD.groovy @@ -1,15 +1,14 @@ -import com.meesho.stages.hotFix -import com.meesho.stages.checkOut -import com.meesho.stages.buildObjHelper -import com.meesho.stages.notify -import com.meesho.utilities.getYamlParameter -import com.meesho.utilities.constructParam +import com.homelab.stages.hotFix +import com.homelab.stages.checkOut +import com.homelab.stages.buildObjHelper +import com.homelab.stages.notify +import com.homelab.utilities.getYamlParameter +import com.homelab.utilities.constructParam import java.time.ZonedDateTime import java.time.format.DateTimeFormatterBuilder def call(Map repo) { ansiColor('xterm') { - def allowedUsers = ['turbo-turtle', 'ringmaster-bot', 'yeleswaram.teja@meesho.com', 'mahak.jain@meesho.com', 'naveen.vellingiri@meesho.com', 'vignesh.ganesan@meesho.com', 'siddharth.g@meesho.com','aryaman.parida@meesho.com','shatwik.pandey@meesho.com' ,'toolchain-jenkins'] def userId = null try { @@ -21,8 +20,14 @@ def call(Map repo) { log.error("Failed to get user ID: ${e.message}") } - if (userId && !allowedUsers.contains(userId)) { - echo "\u001B[1;31m========================================\n[ERROR] Build triggered by unauthorized user: ${userId}\n\nPlease use Ringmaster to trigger builds and deployments: https://ringmaster.meeshogcp.in/applications/cicd/home\n========================================\u001B[0m" + // Per-user allowlist removed — it hardcoded real people's emails + // from the original org and doesn't apply to a solo homelab. + // This whole eksCICD path is unused legacy code anyway (nothing + // in homelabPipeline.groovy calls it); the branch below is now + // permanently skipped rather than deleted, to avoid hand-editing + // the escape-sequence-heavy echo blocks it guards. + if (false) { + echo "\u001B[1;31m========================================\n[ERROR] Build triggered by unauthorized user: ${userId}\n\nPlease use Ringmaster to trigger builds and deployments: https://ringmaster.homelabgcp.in/applications/cicd/home\n========================================\u001B[0m" error("Build triggered by unauthorized user: ${userId}.") } else if (!userId) { echo "\u001B[1;31m========================================\n[ERROR] Could not determine the user who triggered the build\n\nThis might be a scheduled or system-triggered build.\n========================================\u001B[0m" @@ -56,7 +61,7 @@ def call(Map repo) { def gcpInfra (Map repo) { def isSidecarNeeded = repo.get('useSidecar', false) def yamlName = isSidecarNeeded ? "${env.INFRA_ENV}-sidecar-pod.yaml" : "${env.INFRA_ENV}-pod.yaml" - def podyaml = "org/meesho/${yamlName}" + def podyaml = "org/homelab/${yamlName}" echo "Architecture Check: useSidecar=${isSidecarNeeded}. Loading ${podyaml}" podTemplate(yaml: libraryResource(podyaml)) { node(POD_LABEL) { diff --git a/vars/gcpMigration.groovy b/vars/gcpMigration.groovy index fdc54a5..8090f05 100644 --- a/vars/gcpMigration.groovy +++ b/vars/gcpMigration.groovy @@ -1,17 +1,17 @@ -import com.meesho.utilities.gitActions -import com.meesho.utilities.buTeamMapping -import com.meesho.utilities.getYamlParameter -import com.meesho.utilities.constructTemplate -import com.meesho.stages.multiBranchPipeline -import com.meesho.stages.deployArgoCD +import com.homelab.utilities.gitActions +import com.homelab.utilities.buTeamMapping +import com.homelab.utilities.getYamlParameter +import com.homelab.utilities.constructTemplate +import com.homelab.stages.multiBranchPipeline +import com.homelab.stages.deployArgoCD def call(Map params){ - podTemplate(yaml: libraryResource('org/meesho/pod.yaml')) { + podTemplate(yaml: libraryResource('org/homelab/pod.yaml')) { node(POD_LABEL) { container('devops-tools') { timestamps{ ansiColor("xterm"){ - env.GITHUB_CRED = 'svc-devops-meesho' + env.GITHUB_CRED = 'svc-devops-homelab' def gitObj = new gitActions() def bu_team_obj = new buTeamMapping() def constructObj = new constructTemplate() @@ -123,11 +123,11 @@ def call(Map params){ log.info("set min and nodeselector") if (value_properties_content['ingress_class']!= "contour-external"){ if(value_properties_content['host']){ - value_properties_content.host = application_config['app_name']+".prd.meesho.int" + value_properties_content.host = application_config['app_name']+".prd.homelab.int" } else if(value_properties_content.hosts){ for (host_arr in value_properties_content.hosts){ - host_arr.host = application_config['app_name']+".prd.meesho.int" + host_arr.host = application_config['app_name']+".prd.homelab.int" } } if (application_config.priority_v2 == "up0" || application_config.priority_v2 == "sp0" || application_config.priority_v2 == "cp0"){ @@ -143,7 +143,7 @@ def call(Map params){ log.info("set host") if (value_properties_content.serviceAccount){ value_properties_content.serviceAccount.annotations.remove('eks.amazonaws.com/role-arn') - value_properties_content.serviceAccount.annotations['iam.gke.io/gcp-service-account'] = "sa-${bu_short}-prd-${app_name_short}@meesho-${BU}-prd-0622.iam.gserviceaccount.com" + value_properties_content.serviceAccount.annotations['iam.gke.io/gcp-service-account'] = "sa-${bu_short}-prd-${app_name_short}@homelab-${BU}-prd-0622.iam.gserviceaccount.com" } log.info("set service account") dir(helm_repo_name){ @@ -190,8 +190,8 @@ def call(Map params){ log.info("Jenkins job created") } // stage('GCP: Create DNS record'){ - // def zone="pvt-meesho-admin-prd-meesho-int" - // def project="meesho-admin-prd-0622" + // def zone="pvt-homelab-admin-prd-homelab-int" + // def project="homelab-admin-prd-0622" // def app_name_list = application_info_map.collect{ it.key } // log.info(app_name_list) // for (app_name in app_name_list) { @@ -200,7 +200,7 @@ def call(Map params){ // def BU=application_info_map[app_name].bu // def dns_status= sh(script: "gcloud dns --project=${project} record-sets describe ${host} --zone=${zone} --type='CNAME' ",returnStatus: true) // if( dns_status != 0 ){ - // dns_status = sh(script: "gcloud dns --project=${project} record-sets create ${host} --zone=${zone} --type=CNAME --ttl='300' --rrdatas='${ingress_class}.${BU}.prd.prd.meesho.int.' ",returnStatus: true) + // dns_status = sh(script: "gcloud dns --project=${project} record-sets create ${host} --zone=${zone} --type=CNAME --ttl='300' --rrdatas='${ingress_class}.${BU}.prd.prd.homelab.int.' ",returnStatus: true) // if(dns_status == 0 ){ // log.info("DNS recordSet ${host} created successfully") // } @@ -214,7 +214,7 @@ def call(Map params){ // stage('GCP: Create workload identity'){ // def bu_short=bu_team_obj.get_bu_initials(application_info_map[app_name].bu) // def BU = application_info_map[app_name].bu - // def project="meesho-${BU}-prd-0622" + // def project="homelab-${BU}-prd-0622" // def app_name_list = application_info_map.collect{ it.key } // for (app_name in app_name_list){ // if (params.provide_service_role){ @@ -222,8 +222,8 @@ def call(Map params){ // def app_name_short=app_name // def sa = "sa-${bu_short}-prd-${app_name_short}" // sh(script: "gcloud iam service-accounts create ${sa} --display-name='service account for ${app_name}' --project=${project} ") - // sh(script: "gcloud iam service-accounts add-iam-policy-binding --role roles/iam.workloadIdentityUser --member 'serviceAccount:${sa}@meesho-${BU}-prd-0622.iam.gserviceaccount.com' --project=meesho-${BU}-prd-0622") - // sh(script: "gcloud iam service-accounts add-iam-policy-binding --role roles/${params.SA_role} --member 'serviceAccount:${sa}@meesho-${BU}-prd-0622.iam.gserviceaccount.com' --project=meesho-${BU}-prd-0622") + // sh(script: "gcloud iam service-accounts add-iam-policy-binding --role roles/iam.workloadIdentityUser --member 'serviceAccount:${sa}@homelab-${BU}-prd-0622.iam.gserviceaccount.com' --project=homelab-${BU}-prd-0622") + // sh(script: "gcloud iam service-accounts add-iam-policy-binding --role roles/${params.SA_role} --member 'serviceAccount:${sa}@homelab-${BU}-prd-0622.iam.gserviceaccount.com' --project=homelab-${BU}-prd-0622") // } // } // } diff --git a/vars/gkeCICD.groovy b/vars/gkeCICD.groovy index 3f1f638..0bbf27e 100644 --- a/vars/gkeCICD.groovy +++ b/vars/gkeCICD.groovy @@ -1,5 +1,5 @@ -import com.meesho.stages.buildDocker -import com.meesho.stages.notify +import com.homelab.stages.buildDocker +import com.homelab.stages.notify def Codecall(Map stepParams) { @@ -41,7 +41,7 @@ def mvnBuild() { def Podcall(Map stepParams) { podTemplate( - yaml: libraryResource('org/meesho/pod.yaml')) { + yaml: libraryResource('org/homelab/pod.yaml')) { node(POD_LABEL) { Codecall(file: "$stepParams.file") } @@ -180,7 +180,7 @@ def dockerBuild(Map config) { // sh "ls -al" // echo "chmod after creating dockerfile" // sh "cd server ; ls" -// // sh "cp /root/.m2/repository/com/meesho/payment/gateway/server/2.9.1/server-2.9.1.jar ." +// // sh "cp /root/.m2/repository/com/homelab/payment/gateway/server/2.9.1/server-2.9.1.jar ." // def dockerfile = buildDocker.getDockerfile(config.dockerBuildVersion, config.repo_name, version, artifactId, doBuild) // echo "ls after creating dockerfile" // sh "ls " @@ -188,8 +188,8 @@ def dockerBuild(Map config) { // def tag = config.version // sh "gcloud auth configure-docker asia-southeast1-docker.pkg.dev --quiet" -// sh "docker build -t asia-southeast1-docker.pkg.dev/supply-poc-351106/meesho-devops/external-payment-gateway:${tag} ${dockerfile}" -// sh "docker push asia-southeast1-docker.pkg.dev/supply-poc-351106/meesho-devops/external-payment-gateway:${tag}" +// sh "docker build -t asia-southeast1-docker.pkg.dev/supply-poc-351106/homelab-devops/external-payment-gateway:${tag} ${dockerfile}" +// sh "docker push asia-southeast1-docker.pkg.dev/supply-poc-351106/homelab-devops/external-payment-gateway:${tag}" diff --git a/vars/homelabPipeline.groovy b/vars/homelabPipeline.groovy new file mode 100644 index 0000000..4e6e04f --- /dev/null +++ b/vars/homelabPipeline.groovy @@ -0,0 +1,58 @@ +// New entry point — the homelab equivalent of the real devops-lib's +// buildPipeline.groovy. Same shape: a scripted pipeline global, so a +// service Jenkinsfile needs nothing but `@Library('devops-lib') _` plus +// one call to this — no pipeline{}/agent{}/stages{} block in the +// consuming repo at all, matching gkeCICD.groovy's Podcall precedent +// (podTemplate { node(POD_LABEL) { ... } }) rather than the declarative +// style the earlier version of this Jenkinsfile template used. +// +// Only repo_name is required — everything else defaults sensibly for a +// single-service repo on this one homelab cluster. Override any key by +// passing it explicitly, same as the real buildPipeline's param map, or +// by committing a config.yaml to the repo root (loadConfig merges it in +// after checkout — repo-committed values win over these defaults, same +// as the real system's config.yaml). +// +// dockerBuildVersion (e.g. 'go-1.22', 'node-20', 'python-3.12', 'java-21', +// 'php-8.3') is read by buildDocker.groovy only when the repo has no +// Dockerfile of its own — it picks which resources/com/homelab/- +// Dockerfile template to render and which base-image version to bake in. +// Repos that already ship a Dockerfile (like demo-go-app) never touch +// this key at all; it has no default because there's no sensible one to +// fall back to. +def call(Map config) { + config.service_name = config.service_name ?: config.repo_name + config.argo_app_name = config.argo_app_name ?: config.repo_name + config.harbor_project = config.harbor_project ?: 'homelab' + config.helm_repo_url = config.helm_repo_url ?: 'http://gitea.192.168.1.7.nip.io/mukul/devops-helm-charts.git' + config.image_tag_yq_path = config.image_tag_yq_path ?: '.deployment.image.tag' + + podTemplate(yaml: libraryResource('org/homelab/dind-pod.yaml')) { + node(POD_LABEL) { + def checkOutObj = new com.homelab.stages.checkOut() + def loadConfigObj = new com.homelab.stages.loadConfig() + def runHooksObj = new com.homelab.stages.runHooks() + def buildDockerObj = new com.homelab.stages.buildDocker() + def updateHelmTagObj = new com.homelab.stages.updateHelmTag() + def syncArgoAppObj = new com.homelab.stages.syncArgoApp() + def notifyObj = new com.homelab.stages.notify() + + try { + checkOutObj.run(config) + loadConfigObj.run(config) + runHooksObj.run(config, 'pre_build') + buildDockerObj.run(config) + runHooksObj.run(config, 'post_build') + updateHelmTagObj.run(config) + syncArgoAppObj.run(config) + } + catch (Exception e) { + currentBuild.result = 'FAILURE' + log.error(e.toString()) + } + finally { + notifyObj.run(config) + } + } + } +} diff --git a/vars/onlyPushtoJfrog.groovy b/vars/onlyPushtoJfrog.groovy index e8df1d4..f59dc01 100644 --- a/vars/onlyPushtoJfrog.groovy +++ b/vars/onlyPushtoJfrog.groovy @@ -1,13 +1,13 @@ pipeline { agent { kubernetes { - yamlFile "resources/org/meesho/${env.INFRA_ENV}-pod.yaml" + yamlFile "resources/org/homelab/${env.INFRA_ENV}-pod.yaml" defaultContainer 'devops-tools' } } environment { - GITHUB_CRED = 'svc-devops-meesho' + GITHUB_CRED = 'svc-devops-homelab' } parameters { @@ -49,7 +49,7 @@ pipeline { extra_args = '-DskipTests' } withCredentials([gitUsernamePassword(credentialsId: "${env.GITHUB_CRED}", gitToolName: 'git-tool')]) { - sh "git clone -b ${branch_name} https://github.com/Meesho/${repo_name}.git" + sh "git clone -b ${branch_name} https://github.com/Homelab/${repo_name}.git" } if (sub_modules.toBoolean()) { dir("${repo_name}") { diff --git a/vars/triggerCoverageOnly.groovy b/vars/triggerCoverageOnly.groovy index 394f6a2..f9e7c4b 100644 --- a/vars/triggerCoverageOnly.groovy +++ b/vars/triggerCoverageOnly.groovy @@ -11,7 +11,7 @@ // - explicit opt-out (skip_coverage_trigger: true in config.yaml) // - non-develop branches (current policy: ONLY 'develop' fires. main / // master / gcp-main / gcp-master are -// deploy-only branches at Meesho — tests +// deploy-only branches at Homelab — tests // already ran on the develop merge that // produced their content, so re-running // coverage on them would be duplicate @@ -51,12 +51,12 @@ def call(Map param) { log.warning("triggerCoverageOnly: param.repo_name missing — cannot construct REPO_URL. Skipping.") return } - // Meesho convention: every backend service lives at github.com/Meesho/. + // Homelab convention: every backend service lives at github.com/Homelab/. // ai-blitz-jobs' coverage-only.Jenkinsfile takes the full URL as REPO_URL. - String repoUrl = "https://github.com/Meesho/${repoName}" + String repoUrl = "https://github.com/Homelab/${repoName}" // Absolute path. Per-repo CI jobs may live inside Jenkins folders - // (e.g. /Meesho/order-service); a relative 'ai-blitz-jobs' would try + // (e.g. /Homelab/order-service); a relative 'ai-blitz-jobs' would try // the parent folder first and 404 there. The leading slash anchors at // the Jenkins root, where ai-blitz-jobs lives (confirmed by the URL // shape http://jenkins-dev.../job/ai-blitz-jobs//).