3.2 KiB
3.2 KiB
Task 05: Implement the cloudFunctionCICD skeleton
- Type: Small feature
- Source:
BUGS_AND_IMPROVEMENTS_REPORT.md§1.6 (cloudFunctionCICDFlow()is currently a stub containing onlysh 'ls -al'; echo 'Hello World')
Goal
vars/cloudFunctionCICD.groovy actually deploys a GCP Cloud Function. Services that use cloudFunctionCICD { ... } get a working pipeline instead of the current no-op skeleton.
Acceptance Criteria
vars/cloudFunctionCICD.groovyexposesdef call(Map param)(not the current zero-argcloudFunctionCICDFlow()), accepting at minimum:repo_namefunction_nameruntime— one ofnodejs20/python311/go121/ etc.entry_pointregionservice_accountmaintainer
- Stages run in this order:
checkOut(reusesrc/com/meesho/stages/checkOut.groovy)- Optional:
buildObjHelper.run(param.runtime)if the runtime needs a transpile/install step (e.g.node-*→npm install && npm run build). Else skip. gcloud functions deploy ${function_name} --gen2 --runtime ${runtime} --entry-point ${entry_point} --region ${region} --service-account ${service_account} --source .notify(reusesrc/com/meesho/stages/notify.groovy) — same Slack format asbuildPipeline
- Pod selection uses
libraryResource("org/meesho/${env.INFRA_ENV}-pod.yaml")— never an inlinepodTemplate - Auth:
gclouduses ambient Workload Identity via the pod'sservice_account; no key files written to disk - Branch gating: only deploy from
master,main,gcp-main, orgcp-master(match the JFrog/S3 gate inbuildMaven.groovy) unlessparam.deploy_from_any_branch == true - Deployment-tracker callback fires on success/failure (reuse
notify.groovy:postTrackingApi) - One real consumer service uses the new entry point end-to-end as the smoke test
README.md## Adding this library to a new servicegains a Cloud Function example block alongside the existing Jenkinsfile sampledocs/architecture.md§ "Entry points (vars/)" updated —cloudFunctionCICDis no longer flagged as "stub"BUGS_AND_IMPROVEMENTS_REPORT.md§1.6 entry is moved to a Resolved section (or struck-through per repo convention)docs/index.md/docs/wiki/index.mdupdated if the entry point gets new dedicated documentation
Notes / known gotchas
- Use
gcloud functions deploy --gen2explicitly — gen-1 syntax differs (no--source ., different IAM model). Don't write code that works on whichever version happens to be default in the build-tools image. - The user-authorization gate from
eksCICD.groovy:12-26(allowed-users list, Ringmaster banner) is intentionally not copied to this entry point unless DevOps says otherwise. Cloud Functions are deployed less frequently; the gate may be overkill. - If
runtimedoesn't match a knownbuildObjHelpercase (e.g.python311vspython-3.11), prefer extending thebuildObjHelperswitch to recognise the GCP runtime naming rather than inlining build logic incloudFunctionCICD. - This task touches a lot of files (vars/, README, architecture.md, BUGS report) — chunk into reviewable commits if the agent is going autonomous, otherwise one PR is fine.