Build once a day (midnight) ONLY when the branch is changed?

I’m coming from Jenkins here, and I’m trying to figure out how to replicate this in config.yaml.

In Jenkins I can configure the job to poll only at a specific time:

This results in exactly what I want- it builds only at a given time of day, and ONLY when the branch changes.

I’m still learning config.yaml, but the closest I can get seems to be this:

  version: 2
      - buildAndRelease:
              only: master
      - schedule:
          cron: "0 0 * * *"
                - master

However, this results in a build EVERY midnight, even when there are no changes on that branch.

How can I limit this job/workflow so it only triggers when there are changes on the branch?


Good question, you might wish to re-file this in “feature requests”.

It is sort-of possible already, but would require a bit of donkey-work. You could write a shell script to get the hash of your latest commit, and compare it to a stored hash somewhere else (e.g. committed to a Git repo for the purpose). Then in the command to kick off your tests, you’d call this shell script, and call the tests (or not) depending on the result. After the tests, you’d update the stored latest-hash again.

This may not be ideal if you don’t even want to see runs when the code is unchanged, but if you don’t want to eat build minutes and wish to fix the problem now, this might be an OK stop-gap.

(I could use a similar thing, but since my scheduled builds are dependent on whether any of several repos have changed, I can’t expect that to be catered for, and would certainly have to do my own shell magic. However, since these tests only take ~6-7 mins, I can live with it).