Set up multiple configuration files for a project
You can use multiple configuration files in a CircleCI project and set up separate triggers for each one. Each configuration triggers a separate pipeline on a trigger event. If your existing configuration file is getting too large to manage, consider splitting it into multiple files.
Prerequisites
To use multiple configuration files for a project in CircleCI, you will need to meet the following prerequisites:
-
A CircleCI account connected to your code in GitHub. You can sign up for free. Any of CircleCI’s GitHub integrations are supported, read our community forum for background on how this functionality can be used with an org integrated CircleCI’s GitHub OAuth App.
-
A project set up in CircleCI that you want to configure with multiple configuration files. See the Create a project in CircleCI page for steps.
1. Add an additional configuration file to your project repository
Splitting up an existing configuration? If you are following these steps because you have an existing project building on CircleCI and you want to split your configuration into multiple files, you can create a new file in the .circleci/ directory and move over some parts of your existing configuration file to your new YAML files. |
In the GitHub repository for your project add a new CircleCI configuration file in the .circleci/
directory. Your new configuration file must use the .yml
extension but can have any name. Add your required configuration to the file and commit it to your repository.
As your repository is set up as a project in CircleCI, a config.yml
file will exist already. If you do not see .circleci/config.yml
, check which branch you are on. You may have set this up on a non-default branch during the set up process.
Each configuration file will trigger a separate pipeline so it is important that each configuration file is complete with all necessary elements for the pipeline, for example, version
, jobs
, workflows
, commands
, executors
, orbs
etc.
2. Set up a pipeline
Next, add a new pipeline in your CircleCI project settings.
-
In the CircleCI web app select Projects in the sidebar
-
Find your project in the list, select the ellipsis () next to it and select Project Settings
-
Select Pipelines in the sidebar
-
Select Add Pipeline
-
Complete the required form fields:
-
Give your pipeline a descriptive name
-
Ensure GitHub App is selected under Pipeline
-
If you see a Connect button, select it and follow instructions to install the GitHub App for your org.
-
Select the same repository as the project you are building
-
-
Select Save
3. Create a new trigger
Next, create a trigger for your pipeline.
-
Following from the previous step, select Triggers in the sidebar
-
Select Add Trigger
-
Select GitHub App in the dropdown menu
-
Select Next
-
Complete the required form fields:
-
Give your trigger a descriptive name
-
Select your project repository from the dropdown
-
Choose your new pipeline from the "Choose config to run" menu
-
-
Select Save
Conclusion
You have now successfully set up multiple configuration files for your project on CircleCI. Each configuration file will trigger a separate pipeline on the configured trigger events. Push a commit to your code to test this out. You should see both pipelines trigger in the CircleCI web app Pipelines page.