Migrating from Travis CI
So, you’ve decided to try Codefresh? Welcome on board!
We’ll help you get up to speed with basic functionality such as: compiling, testing and building Docker images.
Fork this repository to compare the Travis CI and Codefresh.
Looking into .travis.yml
In the root of this repository you’ll find a file named
.travis.yml this is Travis build descriptor and it describes the different steps that comprise general process (install, script, etc). Let’s quickly review the contents of this file:
Looking into codefresh.yml
In this file, we will look at on
build, freestyle, composition steps to see how to use them to build, test and deploy your repository.
See more details about codefresh.yml steps here.
Let’s start to do the first actions with
.travis.yml example. This file tells Travis CI that this project is written in PHP, and to test Test.php with
phpunit against PHP versions 5.6, 7.0
Codefresh you can use the freestyle step to describe it.
In case if you want to run your tests in parallel you need to create two
Now go to the pipelines of the repository and set the path to certain codefresh.yml for each of pipelines.
Add webhook if you want to start the build automatically after commit and push.
The Build Lifycycle: Installing packages
In Codefresh we use the following steps to describe the flow
- Git Clone
- Launch Composition
Using the steps above we can easily replace the commands that are used in Travis
before_install, install, before_script, script, after_success / after_failure, before_deploy, deploy, after_deploy, after_script
For instance, if you want to install something in your image you can describe it in Dockerfile using the command
or you can install all necessary dependencies before running your test script.
Expression Condition: Skipping the step, Building specific branches
For instance, to skip the
install in Travis you use
We suggest you describe the condition when you want to skip the certain step.
|Only execute the step for the
|Ignore the develop branch and master branch|
|Execute if the string
Breaking the build
If any of the commands in the first four stages of the build lifecycle return a non-zero exit code, the build is broken.
In Travis you can use the
after_success, after_failure, after_script to execute post operations.
In Codefresh we have the similar post-step operations
on_success, on_finish, on_fail.
Or you can just add the capability
fail_fast: false to skip step if it failed and continue performing the following steps.
More information about post-step operations
Travis and Codefresh have the similar syntax to describe the environment variables.
Note: Codefresh allows to use encrypted variables.
See which user provided variables exist in Codefresh
Push to docker registry
More about push step
Deploy on example of AWS Elastic Beanstalk
To deploy to AWS Elastic Beanstalk need to use the following step in Travis and Codefresh
In the pipeline of repository, need to provide the following environment variables
Command line client
|Travis command line client||Codefresh command line client|
See our examples: how to use Codefresh command line as step of codefresh.yml
Validating yml files
|Validating .travis.yml files||Validating codefresh.yml files|