1.version: Specifies the buildspec version.
2.env: Defines environment variables.
3.phases: Contains instructions for the build lifecycle.
4.artifacts: Specifies the output files to be stored.
5.cache: Defines caching to speed up builds (optional).
ex :
version: 0.2
env:
variables:
ENV_VAR_NAME: "value" # Custom environment variable
parameter-store:
SECRET_KEY: "/my/secret/key" # Parameter Store variable
phases:
install:
runtime-versions:
nodejs: 16 # Specify runtime versions
commands:
- echo "Installing dependencies..."
- npm install # Example for Node.js projects
pre_build:
commands:
- echo "Running pre-build steps..."
- npm test # Example for running tests
build:
commands:
- echo "Building the project..."
- npm run build # Example for building a Node.js project
post_build:
commands:
- echo "Post-build steps..."
- echo "Build completed on date
"
artifacts:
files:
- "*/" # Include all files
discard-paths: no
base-directory: build # Directory containing build output
Top comments (0)