-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Phi Huynh
committed
Apr 20, 2017
1 parent
cb3e724
commit ef02e86
Showing
6 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
properties([gitLabConnection('Gitlab')]) | ||
|
||
pipeline { | ||
agent any | ||
stages { | ||
stage('notifyStarted') { | ||
steps { | ||
notifyStarted() | ||
} | ||
} | ||
stage('Build') { | ||
steps { | ||
sh ''' | ||
if [ "$(docker ps -aq -f name=aspnetcore)" ]; then | ||
docker rm -f aspnetcore | ||
fi | ||
if [ "$(docker ps -aq -f name=aspnetcore-uat)" ]; then | ||
docker rm -f aspnetcore-uat | ||
fi | ||
if [ "$(docker ps -aq -f name=aspnetcore-prod)" ]; then | ||
docker rm -f aspnetcore-prod | ||
fi | ||
''' | ||
sh '''cd src | ||
dotnet restore | ||
dotnet build | ||
dotnet publish -c Release -o /artifacts''' | ||
} | ||
} | ||
stage('Tests') { | ||
steps { | ||
parallel( | ||
"Unit Tests": { | ||
sh 'cd tests && dotnet restore && dotnet test --logger "trx;LogFileName=abc.trx"' | ||
|
||
}, | ||
"Integration Tests": { | ||
sh 'echo \'Hello this is integration tests \'' | ||
}, | ||
"End-to-end Tests": { | ||
sh 'echo \'Hello this is end-to-end tests\'' | ||
} | ||
) | ||
} | ||
} | ||
stage('Staging') { | ||
steps { | ||
sh ''' | ||
docker run -d -v devops_artifacts_data:/artifacts -p 5000:80 --name aspnetcore -w /artifacts microsoft/aspnetcore-build:1.0-1.1 dotnet /artifacts/src.dll | ||
''' | ||
} | ||
} | ||
stage('UAT') { | ||
steps { | ||
sh ''' | ||
docker run -d -v devops_artifacts_data:/artifacts -p 5001:80 --name aspnetcore-uat -w /artifacts microsoft/aspnetcore-build:1.0-1.1 dotnet /artifacts/src.dll | ||
''' | ||
} | ||
} | ||
stage('Production') { | ||
steps { | ||
sh ''' | ||
docker run -d -v devops_artifacts_data:/artifacts -p 5002:80 --name aspnetcore-prod -w /artifacts microsoft/aspnetcore-build:1.0-1.1 dotnet /artifacts/src.dll | ||
''' | ||
} | ||
} | ||
} | ||
post { | ||
success { | ||
notifySuccessful() | ||
} | ||
failure { | ||
notifyFailed() | ||
} | ||
} | ||
} | ||
|
||
def notifyStarted() { | ||
updateGitlabCommitStatus name: 'jenkins', state: 'pending' | ||
slackSend (color: '#FFFF00', message: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})") | ||
} | ||
|
||
def notifySuccessful() { | ||
updateGitlabCommitStatus name: 'jenkins', state: 'success' | ||
slackSend (color: '#00FF00', message: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})") | ||
} | ||
|
||
def notifyFailed() { | ||
updateGitlabCommitStatus name: 'jenkins', state: 'failed' | ||
slackSend (color: '#FF0000', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Hosting; | ||
|
||
namespace src | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var host = new WebHostBuilder() | ||
.UseKestrel() | ||
.UseContentRoot(Directory.GetCurrentDirectory()) | ||
.UseIISIntegration() | ||
.UseStartup<Startup>() | ||
.Build(); | ||
|
||
host.Run(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace src | ||
{ | ||
public class Startup | ||
{ | ||
// This method gets called by the runtime. Use this method to add services to the container. | ||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
} | ||
|
||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) | ||
{ | ||
loggerFactory.AddConsole(); | ||
|
||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
|
||
app.Run(async (context) => | ||
{ | ||
await context.Response.WriteAsync("Hello World! Technical Team"); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp1.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="wwwroot\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore" Version="1.0.3" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace tests | ||
{ | ||
public class UnitTest1 | ||
{ | ||
[Fact] | ||
public void Test1() | ||
{ | ||
// Assert.Equal(1==2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp1.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170123-02" /> | ||
<PackageReference Include="xunit" Version="2.2.0-beta5-build3474" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta5-build1225" /> | ||
</ItemGroup> | ||
|
||
</Project> |