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.

질문됨 2년 전556회 조회
2개 답변
1
수락된 답변

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
답변함 2년 전
0

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

답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인