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

73 lines
4.0 KiB
Markdown

<!-- m-wiki: type=top-level slug=entrypoints topic=null base-sha=28f54cf7bef9 generated-at=2026-05-12T00:00:00+00:00 sources=[] -->
> Generated 2026-05-12 at base-sha 28f54cf7bef9. Type: top-level. 0 sources.
# Entry Points
The `vars/` directory contains every Groovy script that is callable from a consumer Jenkinsfile. Each file in `vars/` becomes a global function in the Jenkins pipeline namespace.
## TL;DR
- `eksCICD` is the primary entry point used by all microservices.
- `buildPipeline` is a legacy wrapper kept for backward compatibility.
- `gkeCICD`, `gcpMigration`, `cloudFunctionCICD` are specialised for specific infra targets.
- `createEKSconfigs` and `onlyPushtoJfrog` are utility entry points, not full CI/CD flows.
- `log`, `stageName`, `automationTest` are helper utilities exposed as global functions.
## Mental model
Any `.groovy` file placed in `vars/` is automatically loaded by Jenkins as a global variable/function. Consumer Jenkinsfiles call these directly: `eksCICD(repo)`, `buildPipeline(repo)`, etc. There is no package declaration in `vars/` files — they are scripts, not classes.
## Structure / data flow
```
vars/
├─ eksCICD.groovy Primary entry — all active microservices
├─ buildPipeline.groovy Legacy alias → wraps eksCICD
├─ gkeCICD.groovy GKE-specific pipeline (minimal stub)
├─ gcpMigration.groovy AWS→GCP migration helper
├─ cloudFunctionCICD.groovy Cloud Functions CI/CD
├─ createEKSconfigs.groovy EKS kubeconfig bootstrapper
├─ onlyPushtoJfrog.groovy Pushes JAR to JFrog without full pipeline
├─ automationTest.groovy Automation test runner entry
├─ buildDockerGroovyGke.groovy Docker build for GKE target
├─ log.groovy Global log.info/log.error/log.warn helpers
└─ stageName.groovy Returns stage name string for display
```
## Key code locations
| Symbol | File | What it does |
|--------|------|--------------|
| `call` | `vars/eksCICD.groovy:call` | Main CI/CD flow — auth guard, infra routing |
| `call` | `vars/buildPipeline.groovy:18` | Legacy entry — delegates to eksCICD internals |
| `call` | `vars/gkeCICD.groovy:1` | GKE variant (thin stub) |
| `call` | `vars/cloudFunctionCICD.groovy:1` | Cloud Functions deployment flow |
| `call` | `vars/createEKSconfigs.groovy:1` | EKS kubeconfig bootstrap utility |
| `call` | `vars/log.groovy:1` | Global logging helper (info/error/warn) |
## Sharp edges
- **`vars/` scripts run in the Jenkins CPS interpreter.** Any non-serializable Java object (iterators, closures with complex state) passed from `vars/` to a `@NonCPS` method will throw `NotSerializableException` at runtime.
- **`buildPipeline` is legacy** — do not add new consumers to it. All new services should use `eksCICD`.
- **`log.groovy` shadows Jenkins' built-in `echo`** in some contexts — if you see unexpected log formatting, check whether `log.info` or `echo` was used.
- **`automationTest.groovy` is independent** — it does not go through `eksCICD`; automation test repos call it directly.
- **`scm` is only available in consumer Jenkinsfiles**: the `scm` variable (branch, remote URL, credentials) is injected by the GitHub Branch Source plugin into consumer Jenkinsfiles only — not into `vars/` or `src/` of the shared library. Referencing `scm.branches` in library code causes `MissingPropertyException` at runtime. Use `env.BRANCH_NAME`, `env.GIT_URL`, or `env.CHANGE_*` instead.
See also: [SCM variable scope](build/scm-variable-scope.md)
## Related concepts
- [Architecture](01-ARCHITECTURE.md) — how eksCICD orchestrates the pipeline
- [Build stages](03-BUILD-STAGES.md) — what runs after the entry point selects infra
- [Environment mapping](05-ENVIRONMENT-MAPPING.md) — branch-to-env resolution
- [SCM variable scope](build/scm-variable-scope.md) — why `scm` is unavailable in library code
## Notes
<!-- Anything below is human-owned. wiki-init never reads or modifies content under this heading. -->
---
[← Previous](01-ARCHITECTURE.md) · [Index](../index.md) · [Next →](03-BUILD-STAGES.md)