forked from Lybecker/k8s-friendly-aspnetcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
77 lines (67 loc) · 2.34 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
variables:
solution: '**/*.sln'
buildConfiguration: 'Release'
imgTage: '$(Build.BuildId)'
projects: '**/*.csproj'
assemblyVersion : '1.0.0'
stages:
- stage: ServiceCICD
displayName: Service CI/CD
jobs:
- job: BuildAndTestSolutionAndPublishBuildArtifacts
displayName: Build and test solution and publish artifacts
pool: 'Hosted Ubuntu 1604'
steps:
- task: NuGetToolInstaller@0
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: 'restore'
projects: $(projects)
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: 'build'
projects: $(projects)
arguments: '--configuration $(BuildConfiguration) --no-restore /p:AssemblyVersion=$(assemblyVersion).$(imgTage)'
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: 'test'
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(BuildConfiguration) --no-build'
publishTestResults: true
- task: DotNetCoreCLI@2
displayName: 'dotnet publish'
inputs:
command: 'publish'
publishWebProjects: false
projects: $(projects)
arguments: '--configuration $(BuildConfiguration) --no-build --output $(build.artifactstagingdirectory)' # could use Build.BinariesDirectory as output
zipAfterPublish: false
- task: PublishPipelineArtifact@1
displayName: 'Publish Build Artifacts'
inputs:
path: $(build.artifactstagingdirectory)
artifact: drop
- job: CreateDockerImage
displayName: Build and Push Docker image
pool: 'Hosted Ubuntu 1604'
dependsOn: BuildAndTestSolutionAndPublishBuildArtifacts
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master') # if master branch
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download Build Artifacts'
inputs:
artifact: drop
targetPath: '$(Build.SourcesDirectory)/publish'
- task: Docker@2
displayName: 'Docker build & push'
inputs:
containerRegistry: 'Lybecker Docker Hub'
repository: 'anderslybecker/k8sfriendlyaspnetcore'
command: 'buildAndPush'
Dockerfile: '$(Build.SourcesDirectory)/src/SimpleDockerfile'
buildContext: '$(Build.SourcesDirectory)/publish/src/'
tags: |
$(imgTage)