Is there a way to add build steps mid-build?


I have a build where the steps are not entirely deterministic; we run a subset of the tests depending on what code has changed or whether we are in a fork (cannot run system tests on forks because of credentials). This means that many of my build steps are no-ops.

Is there a way to add build steps programatically mid-build?

This would: (1) remove a bunch of repetitive tasks from my build file, (2) allow me to use concurrency in an effective way.


There isn’t a way to add steps to the current build mid-build.


A clever bash script I guess


Can you provide an example (that would actually be a step in the CircleCI interface)?


Generating a config with a markdown language is probably the easiest, but no, I don’t have an example.


The configuration is a static file at commit hook time, is it not? Is there something that CircleCI sees before reading .circleci/config.yml – some hook where I can write that file on the fly? (You are correct that this would solve for my use case.)


You can provide a specific configuration like this:

                    curl -u ${CIRCLE_API_TOKEN}: \
                    -F revision=${CIRCLE_SHA1} \
                    -F config=@specific_configuration.yml \


It would be great to have better conditional support in circle.yml so that we could e.g. load a cache, run a build and then store a cache if we are running on a certain shard.


You can do that with the checksum feature, if I understand you correctly.


Can you call savecache (and restore cache) from a bash script? I need that level of control.


Not at this time.

The workaround is to put whatever logic you want into a file and the checksum is determines if your cache updates or not.