Visual Studio Team Services : Triggering Build

So for in this series I have shown you to configure Visual Studio Team Services for hosting code in the portal as well as to create build definitions which can trigger the build whenever the code is checked into our remote repository. In this post I am going to show you how to trigger build process by checking in code. Before that, if you want to have a recap of items which I have mentioned above, please go through the links given below.

1. Visual Studio Team Services : Hosting Your First Project Using Git From Visual Studio

2. Visual Studio Team Services : Creating Build Definitions

Adding Code and check in changes to local repo

I have hosted the code in the remote repository and has the build definitions in place. Let's make some changes in the code and check it in to local repo first and then push it into the remote repo to trigger the build.

If you remember from my earlier post that I have checked the main method without any statement in the Program.cs file in our console application. Let's add a Console.WriteLine statement in it as shown below.

I will be using the command prompt to add and commit the files to the local repository. You can also do the same from the Team Explorer window in Visual Studio, provided you have installed the plugin while installing Git client for Windows.

To view the status, execute the following command in the prompt

git status

It will list our Program.cs file in red color which indicates that I am yet to add the file to list which needs to be checked into the local repo

To add a file to the list, add command can be used as shown below

git add .\SampleVSO\Program.cs

If you run the git status command now, it will show our file in green color, indicating that it's pending commit in the repo

Commiting Changes and Syncing to Team Services 

To commit the changes, use the commit statement, syntax is

git commit -m "messge" <file list>

In the above syntax, file list is optional and if you omit it, then all the files which pending for commit will be committed

Usage

     

Notice that when I executed the command in the command prompt, the status is also getting updated in the Team Explorer window in Visual Studio instantly.

So now the changes we made in our code is committed into the local repository, so to sync these to the remote repo, push command can be used as shown in the image below.  Also when the sync is being completed, it is reflected in the Outgoing Commits section in the Team Explorer windows immediately. 

Building Solution.

If you go to the build page in the Team Services portal, you will see an entry for build the project in the Queue tab. There you can see who has triggered it, the build definition which will be used and label for the commit. Click on it will take you to list of changed files in that changeset. 

When the Team Service finshes our build process, it will be moved to the Completed tab as shown below. The outcome can be easily identified by the icon next to the name in the list, a green tick mark indicates a successfull operation where as the red cross mark indicates that the build process has failed.

Viewing Build Output

You can view the output of the build process by double clicking on the entry from Completed list. You will be redirected to a summary page with a tree menu in left side. The summary page has got lot of statistical information such as queued date, started date, and finished date & time, associated work items, how long it took to run the build etc. The left menu has will show the build steps invloved in the process and clicking on each entry will give you detailed information about the things happened in that build step. The successful items will have an tick icon in green color where as the failed ones will have a cross icon in red color.

                            


No Comments

Add a Comment