Last active
January 8, 2026 14:58
-
-
Save muniter/924cb89a357cb033803a0297a99bd7ec to your computer and use it in GitHub Desktop.
AWS CodeBuild buildspec.yml JSON Schema - Forked from @dacci, updated Jan 2026 with Claude Opus 4.5 (cache keys, build-fanout, RETRY patterns, fleet, build-matrix fix). Usage: # yaml-language-server: $schema=https://gist.githubusercontent.com/muniter/924cb89a357cb033803a0297a99bd7ec/raw/buildspec.schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$ref": "#/definitions/BuildSpec", | |
| "definitions": { | |
| "BuildSpec": { | |
| "type": "object", | |
| "required": ["version"], | |
| "additionalProperties": false, | |
| "properties": { | |
| "version": { | |
| "oneOf": [ | |
| { "type": "number", "enum": [0.1, 0.2] }, | |
| { "type": "string", "enum": ["0.1", "0.2"] } | |
| ], | |
| "description": "Buildspec version. Use 0.2 for all new projects." | |
| }, | |
| "run-as": { | |
| "type": "string" | |
| }, | |
| "env": { | |
| "$ref": "#/definitions/Env" | |
| }, | |
| "proxy": { | |
| "$ref": "#/definitions/Proxy" | |
| }, | |
| "batch": { | |
| "$ref": "#/definitions/Batch" | |
| }, | |
| "phases": { | |
| "$ref": "#/definitions/Phases" | |
| }, | |
| "reports": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": { | |
| "$ref": "#/definitions/Report" | |
| } | |
| }, | |
| "artifacts": { | |
| "$ref": "#/definitions/Artifacts" | |
| }, | |
| "cache": { | |
| "$ref": "#/definitions/Cache" | |
| } | |
| } | |
| }, | |
| "YesNo": { | |
| "type": "string", | |
| "enum": ["yes", "no"] | |
| }, | |
| "Map": { | |
| "type": "object", | |
| "additionalProperties": { | |
| "type": "string" | |
| } | |
| }, | |
| "Env": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "shell": { | |
| "type": "string", | |
| "enum": ["bash", "/bin/sh", "powershell.exe", "cmd.exe"] | |
| }, | |
| "variables": { | |
| "$ref": "#/definitions/Map" | |
| }, | |
| "parameter-store": { | |
| "$ref": "#/definitions/Map" | |
| }, | |
| "secrets-manager": { | |
| "$ref": "#/definitions/Map" | |
| }, | |
| "exported-variables": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "git-credential-helper": { | |
| "$ref": "#/definitions/YesNo" | |
| } | |
| } | |
| }, | |
| "Proxy": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "upload-artifacts": { | |
| "$ref": "#/definitions/YesNo" | |
| }, | |
| "logs": { | |
| "$ref": "#/definitions/YesNo" | |
| } | |
| } | |
| }, | |
| "Batch": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "fast-fail": { | |
| "type": "boolean" | |
| }, | |
| "build-graph": { | |
| "type": "array", | |
| "items": { | |
| "$ref": "#/definitions/BatchBuild" | |
| } | |
| }, | |
| "build-list": { | |
| "type": "array", | |
| "items": { | |
| "$ref": "#/definitions/BatchBuild" | |
| } | |
| }, | |
| "build-matrix": { | |
| "$ref": "#/definitions/BuildMatrix", | |
| "description": "Defines tasks with different configurations that run in parallel" | |
| }, | |
| "build-fanout": { | |
| "$ref": "#/definitions/BuildFanout", | |
| "description": "Defines a task that is split into multiple builds running in parallel for test execution" | |
| } | |
| } | |
| }, | |
| "BuildFanout": { | |
| "type": "object", | |
| "required": ["parallelism"], | |
| "additionalProperties": false, | |
| "properties": { | |
| "parallelism": { | |
| "type": "integer", | |
| "minimum": 1, | |
| "description": "The number of builds that will run tests in parallel" | |
| }, | |
| "ignore-failure": { | |
| "type": "boolean", | |
| "description": "Whether failure in any of the fanout build tasks can be ignored" | |
| } | |
| } | |
| }, | |
| "BatchBuild": { | |
| "type": "object", | |
| "required": ["identifier"], | |
| "additionalProperties": false, | |
| "properties": { | |
| "identifier": { | |
| "type": "string" | |
| }, | |
| "buildspec": { | |
| "type": "string" | |
| }, | |
| "debug-session": { | |
| "type": "boolean" | |
| }, | |
| "depend-on": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "env": { | |
| "$ref": "#/definitions/BatchEnv" | |
| }, | |
| "ignore-failure": { | |
| "type": "boolean" | |
| } | |
| } | |
| }, | |
| "BatchEnv": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "compute-type": { | |
| "type": "string", | |
| "description": "The identifier of the compute type to use for the task" | |
| }, | |
| "fleet": { | |
| "type": "string", | |
| "description": "The identifier of the reserved capacity fleet to use for the task. Cannot be used with compute-type." | |
| }, | |
| "image": { | |
| "type": "string", | |
| "description": "The identifier of the image to use for the task" | |
| }, | |
| "privileged-mode": { | |
| "type": "boolean", | |
| "description": "Whether to run the Docker daemon inside a Docker container" | |
| }, | |
| "type": { | |
| "type": "string", | |
| "description": "The identifier of the environment type to use for the task" | |
| }, | |
| "variables": { | |
| "$ref": "#/definitions/Map", | |
| "description": "Environment variables for the build environment" | |
| } | |
| } | |
| }, | |
| "BuildMatrix": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "static": { | |
| "$ref": "#/definitions/StaticBuild" | |
| }, | |
| "dynamic": { | |
| "$ref": "#/definitions/DynamicBuild" | |
| } | |
| } | |
| }, | |
| "StaticBuild": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "ignore-failure": { | |
| "type": "boolean" | |
| }, | |
| "env": { | |
| "$ref": "#/definitions/StaticBuildEnv" | |
| } | |
| } | |
| }, | |
| "StaticBuildEnv": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "privileged-mode": { | |
| "type": "boolean" | |
| }, | |
| "type": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "DynamicBuild": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "buildspec": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "env": { | |
| "$ref": "#/definitions/DynamicBuildEnv" | |
| } | |
| } | |
| }, | |
| "DynamicBuildEnv": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "compute-type": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "image": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "variables": { | |
| "type": "array", | |
| "items": { | |
| "$ref": "#/definitions/Map" | |
| } | |
| } | |
| } | |
| }, | |
| "Phases": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "install": { | |
| "$ref": "#/definitions/InstallPhase" | |
| }, | |
| "pre_build": { | |
| "$ref": "#/definitions/BuildPhase" | |
| }, | |
| "build": { | |
| "$ref": "#/definitions/BuildPhase" | |
| }, | |
| "post_build": { | |
| "$ref": "#/definitions/BuildPhase" | |
| } | |
| } | |
| }, | |
| "OnFailure": { | |
| "type": "string", | |
| "pattern": "^(ABORT|CONTINUE|RETRY(-[0-9]+)?(-.*)?|RETRY-[0-9]+-.*)?$", | |
| "description": "Action on failure: ABORT, CONTINUE, RETRY, RETRY-<count>, RETRY-<regex>, or RETRY-<count>-<regex>. RETRY options are not supported with Lambda compute or reserved capacity." | |
| }, | |
| "InstallPhase": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "run-as": { | |
| "type": "string" | |
| }, | |
| "on-failure": { | |
| "$ref": "#/definitions/OnFailure" | |
| }, | |
| "runtime-versions": { | |
| "$ref": "#/definitions/Map" | |
| }, | |
| "commands": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "finally": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| } | |
| } | |
| }, | |
| "BuildPhase": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": false, | |
| "properties": { | |
| "run-as": { | |
| "type": "string" | |
| }, | |
| "on-failure": { | |
| "$ref": "#/definitions/OnFailure" | |
| }, | |
| "commands": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "finally": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| } | |
| } | |
| }, | |
| "Report": { | |
| "type": "object", | |
| "required": ["files"], | |
| "additionalProperties": false, | |
| "properties": { | |
| "files": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "file-format": { | |
| "type": "string", | |
| "enum": [ | |
| "CUCUMBERJSON", | |
| "JUNITXML", | |
| "NUNITXML", | |
| "NUNIT3XML", | |
| "TESTNGXML", | |
| "VISUALSTUDIOTRX", | |
| "CLOVERXML", | |
| "COBERTURAXML", | |
| "JACOCOXML", | |
| "SIMPLECOV" | |
| ] | |
| }, | |
| "base-directory": { | |
| "type": "string" | |
| }, | |
| "discard-paths": { | |
| "$ref": "#/definitions/YesNo" | |
| } | |
| } | |
| }, | |
| "Artifacts": { | |
| "type": "object", | |
| "required": ["files"], | |
| "additionalProperties": false, | |
| "properties": { | |
| "files": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "name": { | |
| "type": "string" | |
| }, | |
| "discard-paths": { | |
| "$ref": "#/definitions/YesNo" | |
| }, | |
| "base-directory": { | |
| "type": "string" | |
| }, | |
| "exclude-paths": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "enable-symlinks": { | |
| "$ref": "#/definitions/YesNo" | |
| }, | |
| "s3-prefix": { | |
| "type": "string" | |
| }, | |
| "secondary-artifacts": { | |
| "type": "object", | |
| "required": [], | |
| "additionalProperties": { | |
| "$ref": "#/definitions/SecondaryArtifact" | |
| } | |
| } | |
| } | |
| }, | |
| "SecondaryArtifact": { | |
| "type": "object", | |
| "required": ["files"], | |
| "additionalProperties": false, | |
| "properties": { | |
| "files": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "name": { | |
| "type": "string" | |
| }, | |
| "discard-paths": { | |
| "$ref": "#/definitions/YesNo" | |
| }, | |
| "base-directory": { | |
| "type": "string" | |
| }, | |
| "exclude-paths": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| }, | |
| "description": "Paths to exclude from the artifact, relative to base-directory" | |
| }, | |
| "enable-symlinks": { | |
| "$ref": "#/definitions/YesNo", | |
| "description": "Whether internal symbolic links are preserved in ZIP output" | |
| }, | |
| "s3-prefix": { | |
| "type": "string", | |
| "description": "Prefix used when artifacts are output to S3 with BUILD_ID namespace" | |
| } | |
| } | |
| }, | |
| "Cache": { | |
| "type": "object", | |
| "required": ["paths"], | |
| "additionalProperties": false, | |
| "properties": { | |
| "key": { | |
| "type": "string", | |
| "description": "Primary key used when searching or restoring a cache. CodeBuild does an exact match for the primary key. Can include shell commands like $(codebuild-hash-files pnpm-lock.yaml)." | |
| }, | |
| "fallback-keys": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| }, | |
| "maxItems": 5, | |
| "description": "List of fallback keys used sequentially when a cache cannot be found using the primary key. Up to five fallback keys are supported, and each is matched using a prefix search." | |
| }, | |
| "action": { | |
| "type": "string", | |
| "enum": ["restore", "save"], | |
| "description": "Specifies the action to perform on the cache. 'restore' only restores the cache without saving updates. 'save' only saves the cache without restoring a previous version. If not provided, CodeBuild defaults to performing both restore and save." | |
| }, | |
| "paths": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| }, | |
| "description": "Locations of the cache. Contains paths where CodeBuild can find build output artifacts, relative to the original build location or base directory." | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment