zdebra
zdebra

Reputation: 998

CircleCI job approve doesn't execute the job

I have following workflow setup in CircleCI configuration:

// <<< definition of unit_tests, integration_tests and deploy jobs >>>

workflows:
  version: 2
  build-test-and-deploy:
    jobs:
      - unit_tests
      - integration_tests:
          requires:
            - unit_tests
      - build_images:
          requires:
            - integration_tests
          filters:
            branches:
              only:
                - production
      - deploy:
          type: approval
          requires:
            - build_images
          filters:
            branches:
              only:
                - production

The goal is to halt the workflow execution until deploy to production is manually approved. When the workflow execution is fired, it correctly halts before deploy job but after Approve is clicked in the UI, deploy job isn't fired and workflow ends with success.

Do you know what is wrong?

Upvotes: 2

Views: 493

Answers (1)

zdebra
zdebra

Reputation: 998

The CircleCI documentation contains few requirements that such setup has to meet:

  • approval is a special job type that is only available to jobs under the workflow key
  • The hold job must be a unique name not used by any other job.
  • The name of the job to hold is arbitrary - it could be wait or pause, for example, as long as the job has a type: approval key in it. > - All jobs that are to run after a manually approved job must require: the name of that job. Refer to the deploy: job in the above example.
  • Jobs run in the order defined until the workflow processes a job with the type: approval key followed by a job on which it depends.

The config should have one more job, that is not configured above and its only purpose is to halt the execution:

// <<< definition of unit_tests, integration_tests and deploy jobs >>>


workflows:
  version: 2
  build-test-and-deploy:
    jobs:
      - unit_tests
      - integration_tests:
          requires:
            - unit_tests
      - build_images:
          requires:
            - integration_tests
          filters:
            branches:
              only:
                - production
      - hold:
          type: approval
          requires:
            - build_images
          filters:
            branches:
              only:
                - production
      - deploy:
          requires:
            - hold
          filters:
            branches:
              only:
                - production

The main point is that the jobs have to be configured as sequential (deploy job requires halt job to be finished).

Upvotes: 5

Related Questions