Browse Source

Update azure-pipelines.yml for Azure Pipelines

pull/107/head
Huei Feng 6 years ago
parent
commit
3b8cad7e4b
  1. 179
      azure-pipelines.yml

179
azure-pipelines.yml

@ -2,7 +2,6 @@
# Build and test ASP.NET Core projects targeting the full .NET Framework. # Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more: # Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
schedules: schedules:
- cron: "0 */6 * * *" - cron: "0 */6 * * *"
displayName: Daily midnight build displayName: Daily midnight build
@ -10,80 +9,116 @@ schedules:
include: include:
- master - master
always: true always: true
trigger: trigger:
branches: branches:
include: include:
- master - master
pool:
vmImage: 'ubuntu-latest'
variables: stages:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps: - stage: Stage1
- task: UseDotNet@2 jobs:
inputs: - job: Job1
packageType: 'sdk' pool:
version: '3.x' vmImage: ubuntu-latest
- task: CmdLine@2 steps:
displayName: 'install dotnet-ef' - task: UseDotNet@2
inputs: inputs:
script: 'dotnet tool install -g dotnet-ef' packageType: 'sdk'
version: '3.x'
- task: CmdLine@2 - task: DotNetCoreCLI@2
inputs: displayName: 'restore'
script: | inputs:
echo commands command: 'restore'
sed -i '0,/Default[^,]*/s//$(ConnectionStrings)"/g' samples/EShopSample/aspnet-core/src/EShopSample.Web/appsettings.json feedsToUse: 'select'
echo commands executed
- task: CmdLine@2
inputs:
script: |
echo commands
sed -i '0,/Default[^,]*/s//$(ConnectionStrings)"/g' samples/EShopSample/aspnet-core/src/EShopSample.DbMigrator/appsettings.json
echo commands executed
- task: DotNetCoreCLI@2
displayName: 'restore'
inputs:
command: 'restore'
feedsToUse: 'select'
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: 'build' displayName: 'build'
inputs: inputs:
command: 'build' command: 'build'
- task: CmdLine@2
displayName: 'publish'
inputs:
script: |
dotnet publish
- task: CmdLine@2 - stage: Stage2
displayName: 'publish' jobs:
inputs: - job: Job1
script: | pool:
dotnet publish vmImage: windows-2019
- task: CmdLine@2 steps:
displayName: 'drop database' - task: SqlDacpacDeploymentOnMachineGroup@0
inputs: displayName: 'drop database'
script: | inputs:
dotnet ef database drop --project samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/EShopSample.EntityFrameworkCore.DbMigrations.csproj -s samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj -f TaskType: 'sqlInline'
InlineSql: |
- task: CmdLine@2 DECLARE @SQL VARCHAR(MAX);
displayName: 'update database' SET @SQL=''
inputs: SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID)
script: | FROM master..sysprocesses
dotnet ef database update --project samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/EShopSample.EntityFrameworkCore.DbMigrations.csproj -s samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj WHERE dbid=DB_ID('EShopSample');
- task: CmdLine@2 EXEC(@SQL);
inputs:
script: | drop DATABASE EShopSample
cd samples/EShopSample/aspnet-core/src/EShopSample.DbMigrator ServerName: $(ServerName)
DatabaseName: $(DatabaseName)
dotnet run AuthScheme: 'sqlServerAuthentication'
- task: Docker@2 SqlUsername: $(SqlUsername)
displayName: 'build and push docker' SqlPassword: $(SqlPassword)
inputs: continueOnError: true
containerRegistry: $(DockerRegistry)
repository: $(repository)
command: 'buildAndPush' - stage: Stage3
Dockerfile: 'samples/EShopSample/aspnet-core/src/EShopSample.Web/Dockerfile' jobs:
buildContext: . - job: Job1
tags: 'latest' pool:
vmImage: ubuntu-latest
steps:
- task: CmdLine@2
inputs:
script: |
echo commands
sed -i '0,/Default[^,]*/s//$(ConnectionStrings)"/g' samples/EShopSample/aspnet-core/src/EShopSample.Web/appsettings.json
echo commands executed
- task: CmdLine@2
inputs:
script: |
echo commands
sed -i '0,/Default[^,]*/s//$(ConnectionStrings)"/g' samples/EShopSample/aspnet-core/src/EShopSample.DbMigrator/appsettings.json
echo commands executed
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '3.x'
- task: CmdLine@2
displayName: 'install dotnet-ef'
inputs:
script: 'dotnet tool install -g dotnet-ef'
- task: CmdLine@2
displayName: 'update database'
inputs:
script: |
dotnet ef database update --project samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/EShopSample.EntityFrameworkCore.DbMigrations.csproj -s samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj
- task: CmdLine@2
inputs:
script: |
cd samples/EShopSample/aspnet-core/src/EShopSample.DbMigrator
dotnet run
- task: Docker@2
displayName: 'build and push docker'
inputs:
containerRegistry: $(DockerRegistry)
repository: $(repository)
command: 'buildAndPush'
Dockerfile: 'samples/EShopSample/aspnet-core/src/EShopSample.Web/Dockerfile'
buildContext: .
tags: 'latest'

Loading…
Cancel
Save