UPDATE 2019/11/22:
There is a much better way to do this now with WSL2. You can actually host the Docker engine inside WSL2 and have it accessible to windows & Ubuntu without needing to expose without TLS. If you did the steps below previously, remove the export DOCKER_HOST declaration before updating to the new WSL2 version. https://docs.docker.com/docker-for-windows/wsl-tech-preview/
This setup puts the docker engine in Windows on top of Hyper-V, but allows you to control it either from Windows, or within WSL by connecting it to the Windows Docker Engine.
Tell WSL to look for a docker engine on localhost TIP: put the export into your ~/.bashrc so you don’t need to run it ever time. export DOCKER_HOST=tcp://127.0.0.1:2375
Now you will be able to run standard docker commands run new images, show the running containers, etc.
The steps I outline below will work on any build system, such as Jenkins or Team city that can run bash commands. But I have shown VSTS as that is what I am most familiar with.
Screenshot of the final result, with VTSTS showing Truffle test results for each build.
A video where I walk through the entire process end to end.
Example configured project
I have created a repository in GitHub where I have done the below steps. So if you want to just clone it and try it out on your own build server, that will make it easier for you
1. Configure npm development packages for your Truffle project
Add Truffle, TestRPC, Mocha & Mocha JUnit plugin as DevDependencies in your packages.json. This will allow the build server to later install these packages and then execute Truffle commands.
# don't run npm init if your project already has a packages.json
npm init -y
npm install truffle mocha mocha-junit-reporter --save-dev
2. Configure truffle.js
a) remove development network. Truffle test will spin up its own temporary network if there isn’t a development network specified. Just make sure to remove the development network definition if one exists.
b) Mocha test reporter definition. We leave it as “spec” so that it will display the results in the console window while developing locally. Later on the build server we can change the reporter to JUnit, and the output file is already specified here ready for that.
This screenshot shows what the end result looks like. It can be summarised as: get the tests, install the npm packages, configure any environment variables, run the Truffle commands, and collect the test results.
a) Get sources
Define where your code is sitting (e.g. VSTS, Github, Bitbucket, etc.)
b) npm install
The default npm install task. Will look in packages.json and install our dev dependencies so later we can run Truffle, TestRPC, etc.
c) Shell script – environment details and config
An inline script that spits out useful environment information to help debug if things go wrong.
It also importantly replaces the line in our truffle.js to change the test reporter to the console UI, to output the results into a .xml file in JUnit format
# output version details for debugging
node -v
npm -v
npx truffle version
# string replace the mocha reporter to junit output
sed -i -e 's/reporter: "spec"/reporter: "mocha-junit-reporter"/g' truffle.js
d) Shell script – truffle commands
Inline script that executes the local version of Truffle with npx. I like have all 3 lines, so if something breaks we can see where it happened.
# check the contracts compile
npx truffle compile
# run unit tests
npx truffle test
I previously wrote how to install Jekyll on Windows by installing the Windows version of Ruby and then installing the gems that way. I have found another way install Jekyll via the Ubuntu version of Ruby. This is my preferred way now, as the Linux version of these tools are updated more frequently than the Windows versions.
I’ve been using Jekyll to create static websites on GitHub Pages, but I was unsure how to install it with dependencies I wasn’t used to (NodeJS & Ruby). Here is the easiest way to get Jekyll set up on your machine in just a couple of minutes.
TL;DR if you have Chocolatey installed the 2 commands are:
choco install ruby -y
gem install bundler
gem install jekyll
Prerequisite – Chocolatey
You need to have Chocolatey installed on your machine. Chocolatey is the BEST way to install and keep applications updated on windows.
Close and open a new command prompt with Administrator access
Install gem bundler gem install bundler
Install Jekyll gem install jekyll
UPDATE 2016/12/5: if you get an error about SSL, you will need to manually update Ruby Gems, because their certificate expired… Hopefully the new certificate will be bundled in the future http://guides.rubygems.org/ssl-certificate-update/
Now you can use standard Jekyll commands to create a new site and serve it e.g. jekyll new myblog cd myblog jekyll serve
Edits: 2016/12/05: Added details on how to get resolve the Ruby Gems certificate expiring. And added gem bundler which is a new requirement. 2015/12/05: From Jekyll 3.0 you do not need to install NodeJS. This brings it down to just 2 command prompt entries to install Jekyll