Require certain instance of parameterized job

Hello,
I have parameterized job defined as follows:

jobs:
  deploy-job:
    parameters:
      env:
        type: string
    steps:
      .....

and workflow:

workflows:
  main:
    jobs:
    - deploy-job:
      env: staging
    - deploy-job:
      env: production
      requires: #### AND HERE I want to require success of staging deploy

I can have more of those jobs, i.e. before production deploy I could have approval job that also requires deploy to staging succeed, so my workflow would consist of

- deploy-job # env: staging
- approve-prod-deploy
  requires: 
    # what? how to say "requires: deploy-job env: staging"?
- deploy-job # env: prod
  requires:
    approve-prod-deploy

What should I do? How could I set some kind of “alias” for call of parameterized job to use it later to refer specific call in requirements section?
Thank you.

Hi @glebsts !

For parameterized jobs (or any jobs in general), you can also set specific names within the workflow, to ensure uniqueness as such.

In the case above, I believe you can thus do:

- deploy-job:  # env: staging
    name: deploy-staging
- approve-prod-deploy:
    requires: 
      - deploy-staging
- deploy-job:  # env: prod
    name: deploy-prod
    requires:
      - approve-prod-deploy

Thank you!
My mistake, I read job reference, but name can be set in workflow, documentation has it:

1 Like

@glebsts

not at all, and happy to help!
I am super glad you were now able to solve it!

Keep on building! :smiley:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.