-
Notifications
You must be signed in to change notification settings - Fork 4k
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
pipelines: support batch enabled CodeBuild projects in CodePipeline #29592
Comments
While trying to enable batch builds, I encountered a number of other requirements and issues:
The last issue is pretty simple to work around when you encounter it, but could otherwise yield undetectable drift. The first five can all be worked around using the three functions in the attached file, batch-build-workaround.zip. Batch timeout will be set to 1 hour. import { App } from 'aws-cdk-lib';
import { CodeBuildStep, CodePipeline, ... } from 'aws-cdk-lib/pipelines';
import {
doEscapeHatchFixesToEnableBatchBuilds,
doTemplateManipulationsToEnableBatchBuilds,
scheduleEnableBatchBuilds,
} from './batch-build-workaround';
const app = new App();
...
const pipeline1Name = 'pipeline-1';
const pipeline2Name = 'pipeline-2';
const pipeline1 = new CodePipeline(..., { ..., pipelineName: pipeline1Name; });
const stepA = new CodeBuildStep(..., { ..., partialBuildSpec: ... });
scheduleEnableBatchBuilds(pipeline1, pipeline1Name, stepA);
const stepB = new CodeBuildStep(..., { ..., partialBuildSpec: ... });
scheduleEnableBatchBuilds(pipeline1, pipeline1Name, stepB);
pipeline1.addWave(..., { post: [stepA, stepB] });
pipeline1.buildPipeline();
doEscapeHatchFixesToEnableBatchBuilds(pipeline1Name);
const pipeline2 = new CodePipeline(..., { ..., pipelineName: pipeline2Name; });
const stepC = new CodeBuildStep(..., { ..., partialBuildSpec: ... });
scheduleEnableBatchBuilds(pipeline2, pipeline2Name, stepC);
pipeline2.addWave(..., { pre: [stepC] });
pipeline2.buildPipeline();
doEscapeHatchFixesToEnableBatchBuilds(pipeline2Name);
doTemplateManipulationsToEnableBatchBuilds(app.synth()); |
If you came here and also don't know what a valid build specification looks like, here is one example: new CodeBuildStep(..., {
...,
partialBuildSpec: BuildSpec.fromObject({
version: 0.2,
batch: {
'build-list': [
{ identifier: 'Machine_1' },
{ identifier: 'Machine_2' },
{ identifier: 'Machine_3' },
{ identifier: 'Machine_4' },
],
},
}),
}); There is much else you could do, so that's a pretty minimalistic example. See Batch build buildspec reference |
Thanks for creating this feature request and highlighting the issues above. |
Describe the feature
CodeBuild projects can run a single BuildSpec in parallel. This greatly reduces the pipeline wall time for large suites of integration tests or other long running parallelizable tasks. It is achieved by enabling batch building for the project.
The L2 construct
aws-codepipeline.Pipeline
supports this as easy as settingexecuteBatchBuild
on the properties when creating a CodeBuildAction.The L3 construct
pipelines.CodePipeline
maps into a L2 Pipeline, so it seems it would be a simple affair to have a new property for its CodeBuildStep that is conveyed to the L2 construct.Use Case
I want the self-updating feature of the L3 construct, but also want to run tests in parallel without having to rewrite to the L2 construct.
Proposed Solution
Add a new property
CodeBuildStepProps.buildType
(same name as in the Console), that has enum valuesSingle
(default) andBatch
.Or simply
CodeBuildStepProps.executeBatchBuild
with a boolean value same asCodeBuildAction
since theCodeBuildStep
is CodeBuild specific, after all. And this avoids confusing it withCodeBuildStepProps.type
, which I couldn't find in the Console.Other Information
No response
Acknowledgements
CDK version used
2.132.1 (build 9df7dd3)
Environment details (OS name and version, etc.)
Windows 10 Version 22H2
The text was updated successfully, but these errors were encountered: