Crontab: trigger build only if there's a new commit since last build

I trigger a build of a specific branch every hour through crontab. This works fine, but I would like the build to be triggered only if there is a new commit on the branch since the last build.

At present I’m looking at querying the Gitlab API and Gitlab-CI API and may be set a more specific value for the “ref” option of the Trigger API according to what I’ve queried. Is this a way to do it ? Or is there another (simpler) to achieve this ?

I’m a bit lost, so thanks for any advice you could give me.

Well the best solution is to use a CI system such as Jenkins. That would be the best way of doing this and its a lot more robust and less work.

If you want to keep it super small but complex you can use git post-commit hook to trigger an executable (ex: shell script). In this case you can use ‘at’ to trigger a build at a specific time (the top of the next hour) if a commit is added to a specific branch.