Add support for sequential job definitions#854
Open
njakobsen wants to merge 3 commits intojavan:mainfrom
Open
Conversation
Local options override globally set options, but options set on the `every` group do not. It makes sense for the options defined closer to the actual job to override those set further away, so we change the merge order of options to allow options passed to `every` to override those set globally with `set`. We still allow local options set on each job to override those set on the group.
Jobs now support a `sequence` option that will cause jobs with the same `sequence` value to run sequentially when scheduled for the same time. `sequential: true` can be passed to the `every` block to automatically set a common `sequence` value for each contained job. Closes javan#19 Closes javan#696 Closes javan#835
It's likely that since jobs ran in parallel before, there were no dependencies between jobs. Therefore, now that sequential jobs are possible, we should continue execution of the job sequence even if one job fails. To override this and halt the sequence on failure, individual jobs can set `halt_sequence_on_failure: true` to suffix their command with an "&&" instead of a ";".
taketo1113
reviewed
Feb 7, 2026
| module Whenever | ||
| class Job | ||
| attr_reader :at, :roles, :mailto | ||
| attr_reader :at, :roles, :mailto, :sequence, :halt_sequence_on_failure |
Collaborator
There was a problem hiding this comment.
I think it might be better to use a name like chain or combine instead of sequence, to better reflect the actual behavior of the generated crontab. What do you think?
Here is the behavior I confirmed:
every 2.hours do
command "blahblah", sequence: 'backups'
command "foofoo", sequence: 'backups'
command "barbar"
end# crontab
0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /bin/bash -l -c 'blahblah' ; /bin/bash -l -c 'foofoo'
0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /bin/bash -l -c 'barbar'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jobs now support a
sequenceoption that will cause jobs with the samesequencevalue to run sequentially when scheduled for the same time.sequential: truecan be passed to theeveryblock to automatically set a commonsequencevalue for each contained job.Outstanding Questions
Is there a need to configure the command delimiter? i.e. isThis feature has been added.&&always what we want, or do we want to be able to use;so the sequence continues even if one command fails.Note
This PR also includes a previous PR of mine that allows the options set on anThat other PR has been merged intoeveryblock to be overridden by those set on the individual jobs in the block.javan/main.