Zod Validation
Define job arguments with Zod schemas. Input is validated before your handler runs, with auto-generated --help for every job.
A CLI tool to run scripts locally or on Cloud Run. Simple code, zero boilerplate.
GCP Job Runner gives you a CLI to define, discover, and execute jobs from your terminal. Write your logic as a simple function, and run it against any environment — locally on your machine or remotely on Cloud Run — with a single command.
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.
For a more realistic example, see the database migration example — a Firestore migration job that demonstrates idempotent updates, pagination, and environment targeting.