Travis – Continuous Integration
Hello beautiful people, I hope you have heard about CI/CD tools. There are many tools available in the market to help flawlessly build your application such as Travis, Jenkins, Circle CI, Bamboo. In this blog, we will learn about Travis.
So what is Travis, what is continuous integration and why it is important to learn about it? You might find it challenging, but trust me, there is no reason to whack your brains over this. We will learn this together and it will definitely be fun. So let us begin, shall we?
It is a development philosophy rather than merging code together whenever you reach milestones, you should be continuously integrating features as you work on them. It will help you to avoid integration issues. So you can focus on your product and CI will take care of the integration part.
Travis is a fully hosted continuous integration service. It is distributed, open source and incredibly easy. You must have a GitHub account to start working with Travis CI as it will ask you to sign in using GitHub.
First, you will need to create a Travis account using GitHub then you will be able to see your repositories on the Travis dashboard. There is no need to do other configuration steps to read repository from your GitHub account. It will load all the public GitHub repositories associated with your account. If you want to build your private repository with Travis CI then you will need to use their paid version for security. To trigger the Travis CI build when you push the code to the github repository then you will need to configure an important file named `.travis.yml` and add .travis.yml file to your project directory, git, commit, push to trigger a Travis CI build.
The job lifecycle
- before_install: you can run custom commands before installation phase.
- install: specify commands to install project dependencies.
- before_script: This will execute before script phase. You can setup database connection here.
- after_script: It will execute after script phase.
- script: here you will need to specify scripts to test or build your application.
- before_cache: It provides facility to clear the cache.
- deploy: all the deploy configuration will come here.
The following example specifies a Node.js project
language: node_js node_js: - 11.6.0 cache: npm install: - npm ci script: - npm test - npm run build deploy: provider: pages skip-cleanup: true github-token: $GITHUB_TOKEN
To conclude I would like to say that it is important that developers must have a system that supports them to deliver a quality software quickly and efficiently at the best of times.