How to run jobs in a specific window yet allow manual triggers at any time

I have to be missing something simple here. What I need is for my jobs to all kick off between 12AM and 1AM. And for me to be able to manually kick off a job at any time.

The reason we need this is because the entire pipeline takes upwards of an hour to complete. Currently it is kicking off twice per day and inevitably its when we are trying to debug some problems. So it would be nice to banish the daily run to early morning and leave the rest of the day open to getting work done.

What Ive found is that if I use a standard manual trigger and a time based trigger using start: and stop:, that I can’t kick off manual tests outside of the bounds set by start: and stop:.

Here is how a job is currently configured:

resources:

  • name: midnight
    type: time
    icon: clock-outline
    source:
    start: 12:00 AM
    stop: 1:00 AM
    location: America/New_York
  • name: manual-trigger
    type: time
    source:
    interval: 1m

jobs:

  • name: start-pipeline
    plan:
    • get: manual-trigger
      trigger: false
  • name: publishing-tests
    serial_groups:
    • run_serial1
      build_logs_to_retain: 3
      plan:
    • get: manual-trigger
      trigger: true
      passed:
      • start-pipeline
    • get: midnight
      trigger: true
    • task: build
      config:

This is probably because you need at least one version of the time resource to be available before you can manually trigger - once it has successfully checked once (at midnight after you set the pipeline) there will be a valid version so the manual trigger will work without needing a new version of the time resource.

1 Like

I don’t think you even need “manual-trigger” resource in this case.
But as Andy states, you indeed need at least one version of “midnight” resource to be able to manually trigger the pipeline.
One workaround is to configure “midnight” resource to be every minute, wait for the pipeline being triggered, and configure it back to once a day.

We had similar configuration for many pipelines:

  • daily resource
    • triggers a build at least once a day
  • source code reousrce
    • triggers a build on a commit
1 Like

@andy.paine and @artamonovkirill Thank you both so much. That was indeed the answer…to wait for midnight to run at least once. Everything kicked off as desired early this morning and now Im able to run my jobs manually as well. Thank you!