Skip to content

Instantly share code, notes, and snippets.

@ArturKarbone
Last active October 3, 2016 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArturKarbone/c1875a1b99a0d00e87389ee03d36a4c8 to your computer and use it in GitHub Desktop.
Save ArturKarbone/c1875a1b99a0d00e87389ee03d36a4c8 to your computer and use it in GitHub Desktop.
Simple .NET Core CI pipeline
. ".\CI.Functions.ps1"
echo "build: CI Pipeline started"
Push-Location $PSScriptRoot
CleanUpArtifactsDirectory
RestoreSolutionPackages
BuildAndPackageArtifacts src/*
BuildAndPackageArtifacts utilities/*
BuildAndLaunchUnitTests
BuildAndLaunchIntegrationTests
Pop-Location
function CleanUpArtifactsDirectory
{
if(Test-Path .\.artifacts) {
echo "build: Cleaning .\.artifacts"
Remove-Item .\.artifacts -Force -Recurse
}
}
function RestoreSolutionPackages
{
dotnet restore --no-cache --disable-parallel
}
Function BuildTests($location)
{
foreach ($test in ls $location) {
Push-Location $test
echo "build: Building a test project in $test"
& dotnet build -c Development
if($LASTEXITCODE -ne 0) { exit 2 }
Pop-Location
}
}
Function LaunchTests($location)
{
foreach ($test in ls $location) {
Push-Location $test
echo "build: Testing project in $test"
dotnet test -c Development
if($LASTEXITCODE -ne 0) { exit 3 }
#echo %errorlevel%
Pop-Location
}
}
Function BuildAndLaunchUnitTests
{
BuildTests test/*.Tests
LaunchTests test/*.Tests
}
Function BuildAndLaunchIntegrationTests
{
BuildTests test/*.IntegrationTests
LaunchTests test/*.IntegrationTests
}
function BuildAndPackageArtifacts($location)
{
foreach ($src in ls $location) {
Push-Location $src
echo "build: Packaging project in $src"
& dotnet pack -c Release -o ..\..\.artifacts
if($LASTEXITCODE -ne 0) { exit 1 }
Pop-Location
}
}
. ".\CI.Functions.ps1"
echo "build: CB Build started"
Push-Location $PSScriptRoot
CleanUpArtifactsDirectory
RestoreSolutionPackages
BuildAndPackageArtifacts src/*
BuildAndPackageArtifacts utilities/*
BuildAndLaunchUnitTests
BuildAndLaunchIntegrationTests
Pop-Location
function CleanUpArtifactsDirectory
{
if(Test-Path .\.artifacts) {
echo "build: Cleaning .\.artifacts"
Remove-Item .\.artifacts -Force -Recurse
}
}
function RestoreSolutionPackages
{
dotnet restore --no-cache --disable-parallel
}
Function BuildTests($location)
{
foreach ($test in ls $location) {
Push-Location $test
echo "==============build: Building a test project in $test=============="
& dotnet build -c Development
if($LASTEXITCODE -ne 0) { exit 2 }
Pop-Location
}
}
Function LaunchTests($location)
{
foreach ($test in ls $location) {
Push-Location $test
echo "build: Testing project in $test"
dotnet test -c Development
if($LASTEXITCODE -ne 0) { exit 3 }
#echo %errorlevel%
Pop-Location
}
}
Function BuildAndLaunchUnitTests
{
BuildTests test/*.Tests
LaunchTests test/*.Tests
}
Function BuildAndLaunchIntegrationTests
{
BuildTests test/*.IntegrationTests
LaunchTests test/*.IntegrationTests
}
function BuildAndPackageArtifacts($location)
{
foreach ($src in ls $location) {
Push-Location $src
echo "build: Packaging project in $src"
& dotnet pack -c Release -o ..\..\.artifacts
if($LASTEXITCODE -ne 0) { exit 1 }
Pop-Location
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment