Branch dependent workflow manual authorization

workflow
2.0

#1

As specified in the “Orchestrating Workflows” page, you can specify a job that requires manual approval like so:

workflows:
  version: 2
  build-test-and-approval-deploy:
    jobs:
      - build
      - test1:
          requires:
            - build
      - test2:
          requires:
            - test1
      - hold:
         type: approval
         requires:
           - test1
           - test2
      - deploy:
          requires:
            - hold

Is there a way to specify what branches this should apply to? For example, I’d like no manual authorization required for a sandbox/* branch, but I’d like to ask for permission for a release/* branch. Is this possible?


#2

This appears to work just fine. My previous answer suggested editing under the top-level jobs key. In fact, this configuration needs to be defined under the top-level workflow key.

workflows:
  version: 2
  default_test:
    jobs:
      - checkout_code
      #- blah
      - acceptance_test_all_approval:
          type: approval
          requires:
            - checkout_code
            - install_dependencies
            - unit_test
          filters:
            branches:
              only:
                - develop
                - master

I’m not sure if this is possible with jobs of type: approval, but have you had any luck defining a hold job and specifiying a branch filter?

jobs:
  hold:
    filters:
      branches:
        only:
          - master

#3

I just came across a post that answers this question:

**Note it should not be declared it under the main 2.0 config. **


#4

Awesome, I’ll give it a try. Thank you for your help.


#5

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