Cache

class aws_cdk.aws_codebuild.Cache

Bases: object

Cache options for CodeBuild Project.

A cache can store reusable pieces of your build environment and use them across multiple builds.

See:

https://docs.aws.amazon.com/codebuild/latest/userguide/build-caching.html

ExampleMetadata:

infused

Example:

# my_caching_bucket: s3.Bucket


codebuild.Project(self, "Project",
    source=codebuild.Source.bit_bucket(
        owner="awslabs",
        repo="aws-cdk"
    ),

    cache=codebuild.Cache.bucket(my_caching_bucket),

    # BuildSpec with a 'cache' section necessary for S3 caching. This can
    # also come from 'buildspec.yml' in your source.
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2",
        "phases": {
            "build": {
                "commands": ["..."]
            }
        },
        "cache": {
            "paths": ["/root/cachedir/**/*"
            ]
        }
    })
)

Static Methods

classmethod bucket(bucket, *, prefix=None)

Create an S3 caching strategy.

Parameters:
  • bucket (IBucket) – the S3 bucket to use for caching.

  • prefix (Optional[str]) – The prefix to use to store the cache in the bucket.

Return type:

Cache

classmethod local(*modes)

Create a local caching strategy.

Parameters:

modes (LocalCacheMode) – the mode(s) to enable for local caching.

Return type:

Cache

classmethod none()
Return type:

Cache