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


#1

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.


#2

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


#3

A clever bash script I guess


#4

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


#5

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


#6

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.)


#7

You can provide a specific configuration like this:

                    curl -u ${CIRCLE_API_TOKEN}: \
                    -F revision=${CIRCLE_SHA1} \
                    -F config=@specific_configuration.yml \
                    https://circleci.com/api/v1.1/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/tree/$CIRCLE_BRANCH

#8

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.


#9

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

https://circleci.com/docs/2.0/configuration-reference/#savecache


#11

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


#12

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.


#13