Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CodeBuild - How to skip a build

My build is triggered on every push to the repo and on every pull request.

So CODEBUILD_SOURCE_VERSION looks like "pr/8" or "4570d2e7158cfef687af8da31d1ffec7b02e5ca3".

I only want the build to execute for pr branches and pushes to master. What is the best way to achieve this? I don't want to use CodeDeploy as I am just deploying lambdas.

I could write a bash function that checks CODEBUILD_SOURCE_VERSION on the install phase and does an exit 1. But this will create a lot of false positives in our slack channel as these are not really "failed builds".

like image 411
mikestaub Avatar asked Feb 20 '18 20:02

mikestaub


People also ask

How do you skip a stage in CodePipeline?

Currently, CodePipeline does not support skipping a stage/action. The available option to bypass this failing stage would be to edit the pipeline, remove the action and re-run the Pipeline.

How do I stop AWS CodeBuild?

Stop a build (console)Open the AWS CodeBuild console at https://console.aws.amazon.com/codesuite/codebuild/home . Do one of the following: If the build-project-name : build-ID page is displayed, choose Stop build.

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 is batch build in CodeBuild?

CodeBuild batch builds provide restrictions that restrict the number of builds and compute types that can be used for the builds in the batch. If the build role has these permissions, it is possible the builds themselves could bypass these restrictions.


2 Answers

You can configure event filters and do exactly what you want, here is an example of configuration building PRs or pushes on a master branch

enter image description here

It's all here https://docs.aws.amazon.com/codebuild/latest/userguide/sample-github-pull-request.html

like image 162
Alexander Rozhkov Avatar answered Oct 03 '22 05:10

Alexander Rozhkov


Your approach is going to depend on what is triggering your build events and then you'll have to route those events to codebuild. If you're using Github, you could explicitly mark which events you want to trigger your system by creating a webhook that fires on push and pull_request events. That webhook sends a post request into your system, which is going to need some code to convert that request into starting a codebuild build. I don't think you want to parse things after the build has started to see if the build should continue. It is better to not start the build at all if it shouldn't run.

like image 42
jstewart379 Avatar answered Oct 03 '22 07:10

jstewart379