Skip to content

Support Job extension

Compare
Choose a tag to compare
@github-actions github-actions released this 27 Feb 16:56
· 6 commits to master since this release
e711d40

Jobs can now inherit from another job, this will inherit a copy of the parent job's task list, retries and callback retries. The task list can be modified by new methods task_list_prepend(new_tasks...), task_list_prepend_at(task, new_tasks...), task_list_append(new_tasks...) and task_list_append_at(task, new_tasks...).

When searching for Task implementations, we will first look for implementations in the Job's namespace, then in the parent's namespace and last of all without any namespace.

example:

class JobB < JobA
  task_list_prepend :task_a, :task_b # these tasks will be run before all parent tasks
  task_list_append :task_c, task_d # these tasks will be run after all parent tasks
  task_list_prepend_at :task_x, :task_u, :task_v # tasks :task_u and :task_v will be run before :task_x (:task_x can be a parent task)
  task_list_append_at :task_y, :task_u, :task_v # tasks :task_u and :task_v will be run after :task_x (:task_x can be a parent task)

  retries 5 # if we don't specify anything, this job inherits the parent's retries
end