CodeBuild build trigger not checking if the source actually changed?

0

Hi - We started using CodeBuild with source at GitHub. Since we did not want to build on every source push/pull request in Git hub we tried to use the Build Trigger feature with interval set to hour. We are noticing unlike other build systems we have worked with like Jenkins, the CodeBuild blindly rebuilds the source every hour instead of checking if the source code actually changed in GitHub.

Is this how its supposed to work? It's a waste of resources to be blindly building. I am not sure what use is the periodic trigger. Or perhaps I am missing something in the setup. GitHub v2 OAuth connector is being used for CodeBuild to access our GitHub repo.

asked a year ago89 views
2 Answers
1
Accepted Answer

Frequency is not conditional it will trigger the build at the required frequency whether there are changes or not. Is there a particular reason not to build on every commit? It's usually better that a build fails sooner rather than later.

Using a phase within your build spec, for example, pre_build you could run git commands/script to determine if there have been any changes within the last hour. This could set a custom env var which you then use to conditionally wrap the build phase. Additionally, the env var CODEBUILD_RESOLVED_SOURCE_VERSION might allow you to determine if there have been any changes since last build.

RoB
answered a year ago
0

Using the pre build phase to set env var that's a great idea, will give that a go. Thanks.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions