Atlassian recently announced continuous delivery inside Bitbucket with Pipelines - build, test and deploy from Bitbucket. Shortly after Microsoft announced the release of .NET Core 1.0. Pipelines can build Node, Ruby, Python, PHP and anything else you can run in a Docker image - including .NET Core. Take a look how to use Pipelines to not only build a .NET Core project, but test it as well!
The solution comprises of two projects MathDemo and MathDemo.Tests. I have adopted Microsoft’s recommended directory structure with two parent directories - src and test.
You can take a look at the working example here on Bitbucket.
Take a look at Microsoft’s documentation, to understand Unit Testing in .NET Core.
For this example, I have created a simple, and straightforward portable class library in .NET Core and a corresponding test class using Xunit. You can take a look at the code here:
To run a build, you need a valid bitbucket-pipelines.yml file with a branch-specific or default pipeline configuration in the root of your repository.
I used the following…
Rather than a branch-specific configuration, I used default. Using the
dotnet CLI the script runs
dotnet restore to restore the dependencies and tools and
dotnet test to build the necessary projects and execute the unit tests.
And that’s it! Now, every push to Bitbucket triggers a build. You can see an example here.
You also get a really nice summary of each build.
And a detailed output from the build log.
I can’t wait to see what Atlassian do with Pipelines next. For example, I’m hoping for the ability to publish build artifacts or indeed a Docker image ready for deployment.