|
1 |
| -# ASP.NET Core |
2 |
| -# Build and test ASP.NET Core projects targeting .NET Core. |
3 |
| -# Add steps that run tests, create a NuGet package, deploy, and more: |
4 |
| -# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core |
| 1 | +jobs: |
| 2 | +- job: BuildAndTest |
| 3 | + displayName: 'Run tests' |
| 4 | + pool: |
| 5 | + vmImage: 'ubuntu-latest' |
| 6 | + steps: |
| 7 | + - script: dotnet restore --ignore-failed-sources |
| 8 | + displayName: 'dotnet restore (first try)' |
5 | 9 |
|
6 |
| -pool: |
7 |
| - vmImage: 'Ubuntu 16.04' |
| 10 | + - script: dotnet restore --ignore-failed-sources |
| 11 | + displayName: 'dotnet restore (second try)' |
8 | 12 |
|
9 |
| -variables: |
10 |
| - buildConfiguration: 'Release' |
| 13 | + - script: dotnet restore |
| 14 | + displayName: 'dotnet restore (last try)' |
11 | 15 |
|
12 |
| -steps: |
13 |
| -- script: dotnet restore |
14 |
| - displayName: 'dotnet restore' |
| 16 | + - script: dotnet build --configuration Debug |
| 17 | + displayName: 'dotnet build Debug' |
15 | 18 |
|
16 |
| -- script: dotnet build --configuration Debug |
17 |
| - displayName: 'dotnet build Debug' |
| 19 | + - task: DotNetCoreCLI@2 |
| 20 | + displayName: 'dotnet test' |
| 21 | + inputs: |
| 22 | + command: 'test' |
| 23 | + projects: Tests/Tests.csproj |
18 | 24 |
|
19 |
| -- script: dotnet build --configuration Release |
20 |
| - displayName: 'dotnet build Release' |
| 25 | +- job: DockerImage |
| 26 | + displayName: 'Build Docker image' |
| 27 | + condition: and(and(succeeded(), eq(variables['ReleaseBranch'], variables['Build.SourceBranch'])), ne(format('{0}', variables['DockerConnection']), '')) |
| 28 | + dependsOn: BuildAndTest |
| 29 | + pool: |
| 30 | + vmImage: 'ubuntu-latest' |
| 31 | + steps: |
| 32 | + - script: git checkout -f $(Build.SourceBranchName) |
| 33 | + displayName: 'create local tracking branch' |
| 34 | + |
| 35 | + - script: git clean -dfx |
| 36 | + displayName: 'clean build artifacts' |
| 37 | + |
| 38 | + - script: dotnet restore --ignore-failed-sources |
| 39 | + displayName: 'dotnet restore (first try)' |
| 40 | + |
| 41 | + - script: dotnet restore --ignore-failed-sources |
| 42 | + displayName: 'dotnet restore (second try)' |
| 43 | + |
| 44 | + - script: dotnet restore |
| 45 | + displayName: 'dotnet restore (last try)' |
| 46 | + |
| 47 | + - script: dotnet build --configuration Release |
| 48 | + displayName: 'dotnet build Release' |
| 49 | + |
| 50 | + - script: mkdir packages && cp -a /home/vsts/.nuget/packages ./packages/ |
| 51 | + displayName: 'copy nuget package cache for docker' |
| 52 | + |
| 53 | + - task: Docker@2 |
| 54 | + displayName: 'building release docker image' |
| 55 | + condition: and(succeeded(), eq(variables['ReleaseKind'], 'release')) |
| 56 | + inputs: |
| 57 | + containerRegistry: $(DockerConnection) |
| 58 | + repository: $(DockerRegistry) |
| 59 | + command: 'buildAndPush' |
| 60 | + Dockerfile: 'Dockerfile' |
| 61 | + tags: | |
| 62 | + $(Build.BuildId) |
| 63 | + release-latest |
| 64 | + latest |
| 65 | + |
| 66 | + - task: Docker@2 |
| 67 | + displayName: 'building test docker image' |
| 68 | + condition: and(succeeded(), not(eq(variables['ReleaseKind'], 'release'))) |
| 69 | + inputs: |
| 70 | + containerRegistry: $(DockerConnection) |
| 71 | + repository: $(DockerRegistry) |
| 72 | + command: 'buildAndPush' |
| 73 | + Dockerfile: 'Dockerfile' |
| 74 | + tags: test-latest |
| 75 | + |
0 commit comments