Source Class
Source provider definition for a CodeBuild Project.
| Source | aws-codebuild/lib/source.ts |
|---|
Example
ts
declare const myCachingBucket: s3.Bucket;
new codebuild.Project(this, 'Project', {
source: codebuild.Source.bitBucket({
owner: 'awslabs',
repo: 'aws-cdk',
}),
cache: codebuild.Cache.bucket(myCachingBucket),
// BuildSpec with a 'cache' section necessary for S3 caching. This can
// also come from 'buildspec.yml' in your source.
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
build: {
commands: ['...'],
},
},
cache: {
paths: [
// The '**/*' is required to indicate all files in this directory
'/root/cachedir/**/*',
],
},
}),
});
python
# 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/**/*"
]
}
})
)
java
Bucket myCachingBucket;
Project.Builder.create(this, "Project")
.source(Source.bitBucket(BitBucketSourceProps.builder()
.owner("awslabs")
.repo("aws-cdk")
.build()))
.cache(Cache.bucket(myCachingBucket))
// BuildSpec with a 'cache' section necessary for S3 caching. This can
// also come from 'buildspec.yml' in your source.
.buildSpec(BuildSpec.fromObject(Map.of(
"version", "0.2",
"phases", Map.of(
"build", Map.of(
"commands", List.of("..."))),
"cache", Map.of(
"paths", List.of("/root/cachedir/**/*")))))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Bucket myCachingBucket;
new Project(this, "Project", new ProjectProps {
Source = Source.BitBucket(new BitBucketSourceProps {
Owner = "awslabs",
Repo = "aws-cdk"
}),
Cache = Cache.Bucket(myCachingBucket),
// BuildSpec with a 'cache' section necessary for S3 caching. This can
// also come from 'buildspec.yml' in your source.
BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
{ "version", "0.2" },
{ "phases", new Dictionary<string, IDictionary<string, string[]>> {
{ "build", new Struct {
Commands = new [] { "..." }
} }
} },
{ "cache", new Dictionary<string, string[]> {
{ "paths", new [] { "/root/cachedir/**/*" } }
} }
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var myCachingBucket Bucket
codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
Source: codebuild.Source_BitBucket(&BitBucketSourceProps{
Owner: jsii.String("awslabs"),
Repo: jsii.String("aws-cdk"),
}),
Cache: codebuild.Cache_Bucket(myCachingBucket),
// BuildSpec with a 'cache' section necessary for S3 caching. This can
// also come from 'buildspec.yml' in your source.
BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
"version": jsii.String("0.2"),
"phases": map[string]map[string][]*string{
"build": map[string][]*string{
"commands": []*string{
jsii.String("..."),
},
},
},
"cache": map[string][]*string{
"paths": []*string{
jsii.String("/root/cachedir/**/*"),
},
},
}),
})
Properties
Methods
bind(_scope: Construct, _project: IProject): SourceConfigdef bind(self, _scope: Construct, _project: IProject) -> SourceConfigpublic SourceConfig bind(Construct _scope, IProject _project)public SourceConfig Bind(Construct _scope, IProject _project)func Bind(_scope Construct, _project IProject) SourceConfig #Called by the project when the source is added so that the source can perform binding operations on the source.
For example, it can grant permissions to the code build project to read from the S3 bucket.
bitBucket(props: BitBucketSourceProps): ISource@staticmethod def bit_bucket(props: BitBucketSourceProps) -> ISourcepublic static ISource bitBucket(BitBucketSourceProps props)public static ISource BitBucket(BitBucketSourceProps props)func BitBucket(Props BitBucketSourceProps) ISource static #codeCommit(props: CodeCommitSourceProps): ISource@staticmethod def code_commit(props: CodeCommitSourceProps) -> ISourcepublic static ISource codeCommit(CodeCommitSourceProps props)public static ISource CodeCommit(CodeCommitSourceProps props)func CodeCommit(Props CodeCommitSourceProps) ISource static #gitHub(props: GitHubSourceProps): ISource@staticmethod def git_hub(props: GitHubSourceProps) -> ISourcepublic static ISource gitHub(GitHubSourceProps props)public static ISource GitHub(GitHubSourceProps props)func GitHub(Props GitHubSourceProps) ISource static #gitHubEnterprise(props: GitHubEnterpriseSourceProps): ISource@staticmethod def git_hub_enterprise(props: GitHubEnterpriseSourceProps) -> ISourcepublic static ISource gitHubEnterprise(GitHubEnterpriseSourceProps props)public static ISource GitHubEnterprise(GitHubEnterpriseSourceProps props)func GitHubEnterprise(Props GitHubEnterpriseSourceProps) ISource static #s3(props: S3SourceProps): ISource@staticmethod def s3(props: S3SourceProps) -> ISourcepublic static ISource s3(S3SourceProps props)public static ISource S3(S3SourceProps props)func S3(Props S3SourceProps) ISource static #