CircleCI vs Travis CI configuration: comparing build elements
Developer Advocate, CircleCI
CircleCI build pipelines are defined in a .circleci/config.yml
file. This config file differs from other CI/CD services such as Travis CI. Developers interested in migrating their code repository and/or open source project build configurations to CircleCI are sometimes deterred from doing so because they don’t understand the differences between their current CI/CD service configurations and CircleCI’s build configurations. In this post, I’ll compare Travis CI build configuration elements with their CircleCI counterparts, and help translate wherever possible. Since Travis CI and CircleCI are very different systems, not all build elements will be available in CircleCI and vice versa, but I hope this guide can help those looking to learn more about how they are similar and different.
The table below represents the Travis CI build elements and their CircleCI equivalents, when applicable.
Travis CI | CircleCI | Description |
---|---|---|
language: | docker.image | Use the Docker executor to specify an appropriate Docker image for the target language |
dist: | docker, machine, macos | If you need a full VM or macOS builder |
cache components: | restore_cache:, save_cache: | Use the restore and save cache features to control caching in the builds |
before_cache | restore_cache:, save_cache: | Use the restore and save cache features to control caching in the builds |
before_install: | run: | Use the run: step to specify pre install commands |
install: | run: | Use the run: step to specify install commands |
before_script | run: | Use the run: step to specify pre script commands |
script: | run: | Use the run: step to specify execution commands |
after_script: | run: | Use the run: step to specify post execution commands |
before_script: | run: | Use the run: step to specify post execution commands |
deploy: | deploy: | Use the deploy: step to deploy artifacts. |
env: | environment: | Use the environment: element to specify environment variables |
matrix: | workflows | Use the workflows: element to orchestrate jobs |
stage | requires: | Use the requires: element to explicitly require any job dependencies and control parallel builds. |
Summary
I hope this post can serve as a guide for developers that are interested in understanding the differences between Travis CI configurations and a compatible CircleCI build configuration. The reference table listed above shows the common Travis to CircleCI configuration elements and can be a great starting point for Travis CI users interested in migrating their CI/CD pipelines to build, test, and deploy on the CircleCI platform. For a practical example of migrating from Travis CI to CircleCI, check out our documentation that includes a sample translation.
If you get stuck, you can reach out to the CircleCI community via the community forum.