Looking for a Tool which can continuously build and test your Git Hub codes, that too with zero cost ? Travis CI can be a perfect fit for your purpose.

Here in this post, I will share how to Continuously Build and Test your code stored in Git Hub using Travis CI. Travis CI is free for Open source Git Hub projects, so perfect for beginners and constant learners to Integrate and test there software continuously and effectively.

Prerequisites :

  • Git Hub account with a public Repository : Git Hub is an open source web based version control. Once you signup on Git Hub you can create public repositories and push your codes into it. If you are not familiar with using Git Hub, please check the url
  • .Net Core SDK: We are using dot net core to create a console application and we will build this application continously using Travis CI.  If you are not familiar with using .Net Core, please check the link

Lets get Started  – check out the source codes for this session in the Git Hub url

Creating a public repository in Git Hub

  • Sign-in to your Git Hub account, navigate to the Repositories and create a new Repository by clicking the New button.


  • Now create new repository with a unique name, provide description and Click the Create Repository button to create a new repository. Don’t forget to check the checkbox to create a Read me file.


Cloning GitHub repository 

Here in this post we will be creating a dot net core console application for demonstrating the continuous integration using Travis CI. Now go to the Git Hub and copy the clone url.

  • Copying the clone path: Inside the Repository page, click the clone and download button and copy the Clone url .


  • Clone the repository in your machine – Now navigate to the folder path where you want to setup your application. Open the command prompt and type the command git clone “clone url” 


Creating a HelloWorld dot net core console application

  • Create console application : Navigate to the folder created by the clone command. Now open the command prompt and type the command : dotnet new console . This will create a console application in the folder path selected


  • Run the application : Once the application is created, we can build and run the application to confirm everything is fine. In the command prompt type the command dotnet build to build the application. After the successful build, run the command dotnet run to run the application and print Hello World .


Pushing the code to GitHub 

Now that we have created the Application, we can push the codes to our GitHub Repository.

Open the command prompt and type the command git add * . This will add your changes locally.

Now run the command git commit -m “commit message” to commit the changes locally. Now we can type the command git push origin master to push all the changes to GitHub.


Now refresh the GitHub project and see the changes been checked in.


Setting Up Travis CI with GitHub

  • Singing in wit GitHub : Open the Travis CI web using the url and click on the Sign In with GitHub option to link your GitHub account to Travis.


  • Syncing your GitHub repositories with Travis CI: From the Travis home page, click the setting option.


  • Syncing the Repositories : In the settings page, click the sync button. This will display all the GitHub repositories exists for the GitHub account. Now we can integrate the repositories with Travis CI by selecting it in the Legacy Services Integration section.


Continuous Integration of your code using Travis CI

Now that all our setups are completed, we can now do the continuous integration of our application using Travis CI.

  • Creating the travis.yml file : Navigate to the base folder of your application and create a .travis.yml file . Include the below commands in the file. The commands specified in the script section of the file will be executed to ensure the CI process.

File Name : .travis.yml

Sample file contents :

language: csharp

mono: none

dotnet: 2.1.403


– dotnet build

– dotnet run

  • Continuous Integration in action : One the file is created, use the above git commands to push the changes to GitHub project. Now go back to Travis CI web portal and see the build  happening. Once the build is completed, run command will be executed and Hello World message will be printed.


The build will run and succeed and after 15-20 seconds (or refresh manually) the build status against the build will be displayed as Build Passing.

We can also display our build status in the Git Hub. You can check my previous post to learn how to do this. URL