-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
135 lines (119 loc) · 4.29 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: $(majorMinorVersion).$(semanticVersion).$(rev:r)
variables:
majorMinorVersion: 1.0
# semanticVersion counter is automatically incremented by one in each execution of pipeline
# second parameter is seed value to reset to every time the referenced majorMinorVersion is changed
semanticVersion: $[counter(variables['majorMinorVersion'], 0)]
trigger:
- master
stages:
- stage: Build_App
displayName: Build the Application
jobs:
- job: Build_App_Job
displayName: Build the Application
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: UseDotNet@2
displayName: ".NET Core 3.1.x"
inputs:
version: '3.1.x'
packageType: sdk
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI@2
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: -c $(BuildConfiguration) --collect:"XPlat Code Coverage"
displayName: Run Tests
- task: DotNetCoreCLI@2
inputs:
command: custom
custom: tool
arguments: install --tool-path . dotnet-reportgenerator-globaltool
displayName: Install ReportGenerator tool
- script: ./reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"Cobertura"
displayName: Create reports
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml
- task: DotNetCoreCLI@2
displayName: "Publish for Linux-x64"
inputs:
command: 'publish'
publishWebProjects: true
arguments: '-r linux-x64 --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory) --self-contained true'
zipAfterPublish: true
- task: PublishBuildArtifacts@1
displayName: "Upload to job Artifacts"
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'linux-x64'
# Pack a NuGet package
- task: DotNetCoreCLI@2
displayName: Pack a Nuget Package
inputs:
command: 'pack'
outputDir: '$(Build.ArtifactStagingDirectory)'
versioningScheme: 'byBuildNumber'
# Push non test NuGet packages from a build to internal organization Feed
- task: DotNetCoreCLI@2
displayName: Push the Nuget package to repo
inputs:
command: 'push'
searchPatternPush: '$(Build.ArtifactStagingDirectory)/*.nupkg;!$(Build.ArtifactStagingDirectory)/*.Tests.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'elhajjajianas'
- stage: Build_Docker_Image
displayName: Build Docker Image
jobs:
- job: Build_Docker_Image_Job
displayName: Build Docker Image
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
displayName: Build an image
inputs:
command: build
dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
tags: |
$(tag)
# - stage: Deploy
# jobs:
# - deployment: Deploy
# displayName: deploy the App
# environment:
# name: 'QA'
# resourceType: VirtualMachine
# strategy:
# runOnce:
# deploy:
# steps:
# - script: |
# rm -r ~/publish || true
# mkdir -p ~/publish
# unzip '$(Pipeline.Workspace)/linux-x64/*.zip' -d ~/publish
- stage: API_Testing
displayName: Test the API using Newman
jobs:
- job: API_Testing_Job
displayName: Test the API using Newman
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install
npm run build
npm install -g newman
newman run ./postman_collection.json