Install GitVersion on Ubuntu 16.04: a step-by-step guide

One of Red River’s core tenets is our iterative, continuous deployment of projects. As a part of this process, we recently had to provision a new Linux build server and install GitVersion on it. I could not find a clear guide on how to do this so I’ve put together a step-by-step that I hope might make it simpler for others in the future.

Step 1 – Install Mono + Dependencies

GitVersion is written in C# .NET and as such requires the Mono framework in order to run on Linux.

Install Mono:

$ sudo apt-get install mono-complete

GitVersion also requires libcurl3:

$ sudo apt-get install libcurl3

Step 2 – Download GitVersion

Download the latest release from GitHub:

$ wget https://github.com/GitTools/GitVersion/releases/download/v4.0.0-beta.12/GitVersion_4.0.0-beta0012.zip

Unzip it to a new folder:

$ unzip GitVersion_4.0.0-beta0012.zip -d GitVersion

Step 3 – Install GitVersion

At this point you should be able to run:

$ mono GitVersion/GitVersion.exe

However, it will error as it is not being executed from inside a git repository. In order to execute GitVersion in any folder we choose we need to add it to the path.

Step 3.1 – Create GitVersion Wrapper

To make usage simple we will create a wrapper for GitVersion so that we can call it like any other standard Linux command.

First, change into the GitVersion folder:

$ cd GitVersion

Print the current working directory and then copy its value to your clipboard:

$ pwd

Open a new file using your text editor:

$ nano gitversion

Type or paste the following lines into the new file, substituting {current_working_directory} with the contents of the pwd command you previously copied.

mono {current_working_directory}/GitVersion.exe "[email protected]"

Save the file and exit.

Step 3.2 – Add GitVersion to the /usr/local/bin

The final step in the install process is to add our wrapper to the /usr/local/bin folder. This will allow us to execute gitversion from any folder.

To add the wrapper to /usr/local/bin create a symlink:

$ ln -S $(pwd)/gitversion /usr/local/bin/gitversion

Make sure to run the above command in the GitVersion folder previously created to ensure the symlink is created with the correct path.

Step 4 – Using the command

GitVersion should now be installed! To use it you simply execute gitversion from within a git repository, passing any parameters you wish. Full documentation on usage can be found here.

 


This blog post originally appeared on sedders123.me and was reprinted with permission

Step image by Sergio Russo/Flickr, Creative Commons

Leave a Reply

Your email address will not be published. Required fields are marked *

More to Explore