Hi,
I have a CircleCI v2.0 workflows and I also use the ‘approve’ type in my workflow.
I want to ignore the “approve” workflow when matching the specified condition.
My circle.yml like below:
defaults: &defaults
working_directory: ~/ansible_develop
machine:
services:
- docker
version: 2
jobs:
notification:
<<: *defaults
steps:
- checkout
- run:
name: Install dependencies
command: |
pip install --upgrade pip
pip install ansible
- run:
name: Sent the deployed workflow starting email notification
command: |
sh [doing a script]
peer-review:
<<: *defaults
steps:
- checkout
- run:
name: Install dependencies
command: |
pip install --upgrade pip
pip install ansible
- run:
name: Check deploy content
command: |
sh [doing a script]
deploy:
<<: *defaults
steps:
- checkout
- run:
name: Add git identify
command: |
if [ "${CIRCLE_BRANCH}" == "master" ];
then
echo "The master branch deploy needs be approved"
else
git config --global user.email "circleci@workflows.jobs"
git config --global user.name "circleci"
fi
- run:
name: Install dependencies
command: |
if [ "${CIRCLE_BRANCH}" == "master" ];
then
echo "The master branch deploy needs be approved"
else
sudo apt-get update -y && sudo apt-get -y install pssh
pip install --upgrade pip
pip install ansible
fi
- run:
name: Major deploy tasks
command: |
if [ "${CIRCLE_BRANCH}" == "master" ];
then
echo "The master branch deploy needs be approved"
else
sh [doing the deploy script]
fi
- run:
name: If failed
command: |
sh $PWD/mail_sent.sh
cd /tmp && ansible-playbook job-fail.yml
when: on_fail
workflows:
version: 2
Staging-CICD-workflows:
jobs:
- notification:
filters:
branches:
ignore: master
- peer-review:
type: approval
filters:
branches:
only: staging
- deploy:
requires:
- peer-review
My request like(I am using colloquialism to express):
(In the Job) if script return 1 then ignore peer-review and directly going to the deploy job.
But, I tried its always “hold” on peer-review stage.
Could accomplish my requirement?
Thank you