Ethereum DevOps with Truffle, TestRPC & Visual Studio Team Services

I have been working on automating the compilation and testing of Ethereum solidity contracts, via the use of Truffle. I’ve got the test results being published back into the portal, allowing me to see on each commit if my code still compiles and passes my tests.

My final system will allow you to run “truffle test” locally to see standard test output, but will modify the test runner on the server to output it as JUnit format.

The Build system

The system uses the Visual Studio Team Services (VSTS) build engine to automate this. You can sign up for free, and get unlimited private Git repos.
You can have the code hosted on any Git provider. So either within VSTS itself, or GitHub, BitBucket, etc.

Prepare truffle.js

Create a build agent

VSTS does provide hosted build agents, which are generic and can build standard .Net projects, Xamarin, etc. But because we are going to use npm packages installed globally on the box to handle the Truffle builds

Install npm packages (make sure you open a new PowerShell window so that node is in your path)

npm install -g npm

npm install -g –production windows-build-tools

npm install -g ethereumjs-testrpc

npm install -g truffle

npm install -g mocha

npm install -g mocha-junit-reporter

Restart the build agent so that all new paths are working

Configure VSTS build

Create a new variable with the path to where the npm global path is, for the user you installed the npm packages on abovevariable name: npm.path
variable value: path to npm packages e.g. C:\Users\<user>\AppData\Roaming\npm