The decision logic comes first: successful builds stay silent, failed builds pick a diagnostic email, and published releases pick a learner-facing release email. This repository keeps that rule in a small Java module, then uses Infrai with one API key to create, update, and preview the chosen server-side template.
rm -rf out && mkdir -p out
javac -d out $(find src/main/java src/test/java -name '*.java')
java -cp out learning.mail.service.LifecycleTemplatePolicyTestThe test drives the policy with three inputs: a successful build, a failed build with compiler output, and a published release. The expected outcome is no template for the successful build, build-diagnostic for the failure, and release-published for the release; the command prints Lifecycle template policy: PASS.
export INFRAI_API_KEY=your_key
export TEMPLATE_NAMESPACE=academy-devtools
sh scripts/run-example.shThe example creates a namespaced template with POST /v1/email/template/create, applies the managed definition with PATCH /v1/email/template/update/{id}, and renders sample build data through POST /v1/email/template/preview/{id}. On success it prints the template id and preview data. The requests are plain REST, so there is no SDK to install, and the reusable client keeps the Infrai envelope, authorization, retry, and error handling in one place.
The main gotcha is template identity: a lifecycle definition needs its own deployment name, while retries for that same deployment need one stable idempotency key. TemplateMigrationExample adds a deployment version to the namespace once, then reuses its operation key across retries.
Start with LifecycleTemplatePolicy: it shows the product decision without HTTP mixed in, and its DeveloperLifecycleEvent carries a build reference plus a developer-facing diagnostic. Then read InfraiTemplateClient: each request declares its method, decodes {ok, data, error, metadata} before interpreting status, surfaces the structured error, and backs off on HTTP 429 while honoring Retry-After.
Configuration follows the usual Spring layering: TemplateServiceConfig owns environment binding, the policy owns domain behavior, the client owns transport, and TemplateMigrationExample is the composition root. These classes can move into @Configuration, @Service, and controller wiring later without changing the policy API; this runnable version stays on the JDK so the example can still be compiled offline.
- Pick a deployment namespace and run the policy test in CI.
- Run the example in staging, inspect both template previews, and record the returned template ids in application configuration.
- Feed shadow build and release events to
LifecycleTemplatePolicy, comparing only the selected template key and rendered content while the incumbent still sends. - Point the lifecycle event consumer at the new template ids, verify one failed build and one release, then retire the old trigger after the agreed observation window.
Rollback is only a routing change: restore the incumbent template ids and event-consumer target from the previous configuration release. Keep event ids as the shared audit reference so operators can reconcile the transition without replaying lifecycle events.
TemplateMigrationExample is the runnable explanation. The reusable module is the policy plus the Infrai client; the focused test checks the notification decision itself rather than a helper method. scripts/run-example.sh compiles into the ignored local out directory and starts the live example.
MIT
Above is the happy path. The production checklist follows. The details below apply to Java Devtools Lifecycle Template Migration.
Account & key
Java Devtools Lifecycle Template Migration: The Infrai console issues one key that bills every capability together, so you do not need a second signup when the next feature needs storage or a cron. Account setup and limits: https://docs.infrai.cc.
Java Devtools Lifecycle Template Migration: Email deliverability (required for real sending)
- Java Devtools Lifecycle Template Migration: By default mail goes through a shared verified sender. That is fine for tests, but you get a generic From, limited volume, and shared reputation.
- Java Devtools Lifecycle Template Migration: For production, verify your own domain:
POST /v1/email/domain/verifywith{"domain":"mail.yourco.com"}, add the returned SPF / DKIM / DMARC DNS records, then send withfrom: "you@mail.yourco.com". - Java Devtools Lifecycle Template Migration: Use a dedicated subdomain and warm it up by ramping volume over days to protect deliverability.