How to Run the Same Job Twice in a Single Workflow

Overview

You may want to run the same job twice in a single workflow. This syntax applies a name to jobs, which allows them to be called separately.

Syntax Examples

Job Names

workflows:
my-awesome-workflow:
jobs: 
- build-1
- build-2:
name: first-build-2
- build-2:
name: second-build-2

Example Pipeline in the UI

Screenshot_2023-05-29_at_11.56.59_AM.png

Job Names with Requires

This example utilizes job names and requires to re-run the same job twice in a workflow:

workflows:
my-awesome-workflow:
jobs: 
- build-1
- build-2:
name: first-build-2
- build-2:
requires: 
- first-build-2

Example Pipeline in the UI

Screenshot_2023-05-29_at_11.34.05_AM.png

Additional Resources

If you need to run a parameterized job twice in a workflow with different arguments, please refer to our documentation on utilizing Matrix Jobs:

Was this article helpful?
1 out of 1 found this helpful

Comments

0 comments

Article is closed for comments.