Trigger a build with a specific branch that is not in the config file

I have a build config that monitors 2 branches (main and qa-main). How can I manually trigger a build for a specific branch that is NOT in the config file? Can that be done from the circleci interface or do I need to make an API call?


The config.yml is very tied to the project it is defined in as this is the entry point for circleci. So if you have a number of branches it is from within the config.yml you must be able to at least start the process of selecting what to do. What you can do is

  • While in many areas of the docs it is stated that you can only have a single config.yml there is also a feature called “Dynamic Configuration”
  • The other option is to have another project defined with a different config.yml defined. You then use the API (via a curl statement) to start this project.

I’ve not used Dynamic Configuration, but I have started to use the API call as it allows the main projects which are under the control of the development teams to have a simple and very static config.yml that causes another project to be started which is where the main config.yml is located, this file is currently being actively worked on and so changes a lot.

Below is an example of the API call I make - as you can see I can pass parameters to the new job and the curl command has been wrapped so that an exit code can be correctly returned to CircleCI.

  - run:
       name: Start the main job via a curl call
       command: |
                  curl -s -o /dev/null -w '%{http_code}' \
                       --request POST \
                       --url \
                       --header 'Circle-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
                       --header 'content-type: application/json' \
                       --data "{\"parameters\":{ \
                                               \"PULL_BRANCH\":\"${CIRCLE_BRANCH}\", \
                                               \"PULL_NUM\":\"${CIRCLE_BUILD_NUM}\", \
                                               \"PULL_USER\":\"${CIRCLE_USERNAME}\", \
                                               \"PULL_CALLING_REPO_JOB_NAME\":\"${CIRCLE_PROJECT_REPONAME}\" \
                                      } \
                               }" \
         if [ "$STATUS" != "201" ]; then
            echo code $STATUS returned
            exit 1