Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On CircleCI, how can I trigger one build after another, but only if the first is green

Tags:

circleci

I've managed to create a CircleCI build that triggers a subsequent build using their API using curl. I've added this to my circle.yml:

test:
 override:
  - mvn test -s settings.xml
  - mvn deploy -Prun-its -s settings.xml
  - curl -v -X POST https://circleci.com/api/v1/project/alexec/docker-maven-plugin/tree/master?circle-token=$CIRCLE_TOKEN

How do I trigger only if all of the previous steps are green?

like image 883
Alex Collins Avatar asked Apr 27 '15 19:04

Alex Collins


2 Answers

I think you should do this in the deployment section: Since this is - by definition - only run if everything is fine, this should do the trick.

See their documentation on deployment for details. There it says:

These commands are triggered only after a successful (green) build.

like image 66
Golo Roden Avatar answered Sep 28 '22 01:09

Golo Roden


You should have a requires variable in your job that you want to run only if the previous job has run. So you give the requires variable a value of the job name that you want to succeed first before the jobs resume running.

See this example: https://circleci.com/docs/2.0/configuration-reference/

like image 40
Dawei Avatar answered Sep 27 '22 23:09

Dawei