Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Queue CodeBuild tasks

Is there are way to make a CodeBuild project execute build tasks one at a time (max concurrency = 1)?

I know one of the selling points of CodeBuild is that you can run builds concurrently and I like that feature.

However, for this one specific project, I NEED to make sure only one CodeBuild build task for this project executes at a time. If there is an incoming "startBuild" request while a previous request is still running, I want it to be queued and wait until the previous build task if finished.

As additional info on the project, this project runs integration tests across our various APIs (serverless APIs and legacy APIs on EC2) and running those tests concurrently may cause the tests to fail due to their setup and teardown procedures.

like image 832
Noel Llevares Avatar asked Dec 19 '17 16:12

Noel Llevares


People also ask

Why is CodeBuild queued?

If the build project does not have a concurrent build limit set, builds are queued if the number of running builds reaches the concurrent build limit for the platform and compute type. The maximum number of builds in a queue is five times the concurrent build limit.

What tasks do CodeBuild service eliminate?

CodeBuild compiles source code, runs tests, and produces packages that are ready to deploy. CodeBuild eliminates the need to provision, manage, and scale your own build servers. CodeBuild automatically scales up and down and processes multiple builds concurrently, so your builds don't have to wait in a queue.

How do you assume a role in CodeBuild?

CodeBuild uses the CodeBuild service role as the default AWS credential in the build container and Docker runtime. Export the AssumeRole credentials as environment variables. Then, pass these variables into the Docker runtime by using the --build-arg parameter for docker build.


2 Answers

I am from the AWS CodeBuild team. Thanks for your feedback. At this point the feature you requested isn't supported. We'll pass along the feedback to our product management team so they may consider adding it to our future roadmap.

However, you maybe able to implement something at your end by using CodeBuild's Build notifications feature. At a high level, you could listen to the CloudWatch Events sent by CodeBuild to find when a build completes, and at that time "release" a new build from a queue that you maintain at your end.

like image 176
sdhillon Avatar answered Oct 21 '22 09:10

sdhillon


Update (2021-02-17)

AWS CodeBuild just added the ability to define a maximum number of concurrent builds per project.

enter image description here

Reference: https://docs.aws.amazon.com/codebuild/latest/userguide/create-project-console.html#create-project-console-project-config

like image 33
Noel Llevares Avatar answered Oct 21 '22 07:10

Noel Llevares