Zod Validation
Define job arguments with Zod schemas. Input is validated before your handler runs, with auto-generated --help for every job.
Schema-driven CLI jobs that run locally during development and on Cloud Run in production. Same code, same secrets, same behavior.
Define a job with a Zod schema:
import { z } from "zod";
import { defineJob } from "gcp-job-runner";
export default defineJob({
description: "Count down and exit",
schema: z.object({
seconds: z.number().default(10).describe("Number of seconds to count down"),
}),
handler: async ({ seconds }) => {
for (let i = seconds; i > 0; i--) {
console.log(`${i}...`);
await new Promise((resolve) => setTimeout(resolve, 1000));
}
console.log("Done!");
},
});Run it locally:
job local run stag countdown --seconds 5Run it on Cloud Run:
job cloud run stag countdown --seconds 5The cloud command builds a Docker image, pushes it to Artifact Registry, and streams logs back to your terminal. Images are cached by content hash — if your code hasn't changed, there's no rebuild, no deploy, straight to execution.