Skip to content

Commit e09250b

Browse files
authored
feat(codebuild): allow setting queued timeout (#13467)
Closes #11364 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent e567a41 commit e09250b

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

packages/@aws-cdk/aws-codebuild/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -617,3 +617,31 @@ if (project.enableBatchBuilds()) {
617617
console.log('Batch builds were enabled');
618618
}
619619
```
620+
621+
## Timeouts
622+
623+
There are two types of timeouts that can be set when creating your Project.
624+
The `timeout` property can be used to set an upper limit on how long your Project is able to run without being marked as completed.
625+
The default is 60 minutes.
626+
An example of overriding the default follows.
627+
628+
```ts
629+
import * as codebuild from '@aws-cdk/aws-codebuild';
630+
631+
new codebuild.Project(stack, 'MyProject', {
632+
timeout: Duration.minutes(90)
633+
});
634+
```
635+
636+
The `queuedTimeout` property can be used to set an upper limit on how your Project remains queued to run.
637+
There is no default value for this property.
638+
As an example, to allow your Project to queue for up to thirty (30) minutes before the build fails,
639+
use the following code.
640+
641+
```ts
642+
import * as codebuild from '@aws-cdk/aws-codebuild';
643+
644+
new codebuild.Project(stack, 'MyProject', {
645+
queuedTimeout: Duration.minutes(30)
646+
});
647+
```

packages/@aws-cdk/aws-codebuild/lib/project.ts

+10
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,15 @@ export interface CommonProjectProps {
575575
* @default - no log configuration is set
576576
*/
577577
readonly logging?: LoggingOptions;
578+
579+
/**
580+
* The number of minutes after which AWS CodeBuild stops the build if it's
581+
* still in queue. For valid values, see the timeoutInMinutes field in the AWS
582+
* CodeBuild User Guide.
583+
*
584+
* @default - no queue timeout is set
585+
*/
586+
readonly queuedTimeout?: Duration
578587
}
579588

580589
export interface ProjectProps extends CommonProjectProps {
@@ -869,6 +878,7 @@ export class Project extends ProjectBase {
869878
cache: cache._toCloudFormation(),
870879
name: this.physicalName,
871880
timeoutInMinutes: props.timeout && props.timeout.toMinutes(),
881+
queuedTimeoutInMinutes: props.queuedTimeout && props.queuedTimeout.toMinutes(),
872882
secondarySources: Lazy.any({ produce: () => this.renderSecondarySources() }),
873883
secondarySourceVersions: Lazy.any({ produce: () => this.renderSecondarySourceVersions() }),
874884
secondaryArtifacts: Lazy.any({ produce: () => this.renderSecondaryArtifacts() }),

packages/@aws-cdk/aws-codebuild/test/test.project.ts

+43
Original file line numberDiff line numberDiff line change
@@ -960,4 +960,47 @@ export = {
960960
test.done();
961961
},
962962
},
963+
964+
'Timeouts': {
965+
'can add queued timeout'(test: Test) {
966+
// GIVEN
967+
const stack = new cdk.Stack();
968+
969+
// WHEN
970+
new codebuild.Project(stack, 'Project', {
971+
source: codebuild.Source.s3({
972+
bucket: new s3.Bucket(stack, 'Bucket'),
973+
path: 'path',
974+
}),
975+
queuedTimeout: cdk.Duration.minutes(30),
976+
});
977+
978+
// THEN
979+
expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', {
980+
QueuedTimeoutInMinutes: 30,
981+
}));
982+
983+
test.done();
984+
},
985+
'can override build timeout'(test: Test) {
986+
// GIVEN
987+
const stack = new cdk.Stack();
988+
989+
// WHEN
990+
new codebuild.Project(stack, 'Project', {
991+
source: codebuild.Source.s3({
992+
bucket: new s3.Bucket(stack, 'Bucket'),
993+
path: 'path',
994+
}),
995+
timeout: cdk.Duration.minutes(30),
996+
});
997+
998+
// THEN
999+
expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', {
1000+
TimeoutInMinutes: 30,
1001+
}));
1002+
1003+
test.done();
1004+
},
1005+
},
9631006
};

0 commit comments

Comments
 (0)