Continuous integration is a development practice where every commit to a repository is built and tested.
I wanted to build my small .NET application, which is held in a private BitBucket repository, without having to pay anything for a CI service. I don’t need all the bells and whistles, I just want a service to build my code and run the tests (I’m too lazy to run the tests myself).
Azure Web Apps does half of this already. It integrates with BitBucket and GitHub, and will fetch my project on every commit and build it. It’s just missing the last mile of being able to run the tests and notify me of any problems.
The good news, is that you can customise your build script, and get it to do the remaining pieces.
To do that, you’ll need to generate a build script, to do that you’ll need the Azure CLI tooling, which is a node.js module. I’m assuming you’ve already got Node.js installed.
Here’s the process:
Install Azure CLI:
Create the deployment script:
There are lots of options here, if you type…
…you’ll get a list of options.
This is what I used for a traditional ASP.NET web application:
Customise the deployment script:
Now you can add some lines to build your tests project, and run the tests.
Identify the point in the build script after the nuget packages have been restored, and the project has been built, and insert this line, to build your project containing the tests:
Then you can run the tests, and store the output to a file:
I then use curl to call the sendgrid API, to email me the test output file:
The code should be immediately after the test runner.
There you are. After you’ve added the deployment files to the repo, and pushed it, Azure Web Apps should start building and running your tests. You might want to extend this further, and send emails when deployments have been successful/unsuccessful.