Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(codebuild): allow setting concurrent build limit #14099

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/@aws-cdk/aws-codebuild/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -648,3 +648,17 @@ new codebuild.Project(stack, 'MyProject', {
queuedTimeout: Duration.minutes(30)
});
```

## Limiting concurrency

By default if a new build is triggered it will be run even if there is a previous build already in progress.
It is possible to limit the maximum concurrent builds to value between 1 and the account specific maximum limit.
By default there is no explicit limit.

```ts
import * as codebuild from '@aws-cdk/aws-codebuild';

new codebuild.Project(stack, 'MyProject', {
concurrentBuildLimit: 1
});
```
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,13 @@ export interface CommonProjectProps {
* @default - no queue timeout is set
*/
readonly queuedTimeout?: Duration

/**
* Maximum number of concurrent builds. Minimum value is 1 and maximum is account build limit.
*
* @default - no explicit limit is set
*/
readonly concurrentBuildLimit?: number
}

export interface ProjectProps extends CommonProjectProps {
Expand Down Expand Up @@ -917,6 +924,7 @@ export class Project extends ProjectBase {
name: this.physicalName,
timeoutInMinutes: props.timeout && props.timeout.toMinutes(),
queuedTimeoutInMinutes: props.queuedTimeout && props.queuedTimeout.toMinutes(),
concurrentBuildLimit: props.concurrentBuildLimit,
secondarySources: Lazy.any({ produce: () => this.renderSecondarySources() }),
secondarySourceVersions: Lazy.any({ produce: () => this.renderSecondarySourceVersions() }),
secondaryArtifacts: Lazy.any({ produce: () => this.renderSecondaryArtifacts() }),
Expand Down
23 changes: 23 additions & 0 deletions packages/@aws-cdk/aws-codebuild/test/test.project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,29 @@ export = {
},
},

'Maximum concurrency': {
'can limit maximum concurrency'(test: Test) {
// GIVEN
const stack = new cdk.Stack();

// WHEN
new codebuild.Project(stack, 'Project', {
source: codebuild.Source.s3({
bucket: new s3.Bucket(stack, 'Bucket'),
path: 'path',
}),
concurrentBuildLimit: 1,
});

// THEN
expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', {
ConcurrentBuildLimit: 1,
}));

test.done();
},
},

'can be imported': {
'by ARN'(test: Test) {
const stack = new cdk.Stack();
Expand Down