-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBackend-Continues-Build-BP.yaml
More file actions
201 lines (198 loc) · 8.73 KB
/
Backend-Continues-Build-BP.yaml
File metadata and controls
201 lines (198 loc) · 8.73 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Variable 'artifactName' was defined in the Variables tab - This is from my fix branch
# Agent Queue 'Azure Pipelines' was used with unrecognized Agent Specification, vmImage property must be specified to determine image - https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#software
variables:
- name: 'BuildParameters.configuration'
value: release
- name: NUGET_PACKAGES
value: $(Pipeline.Workspace)/.nuget/packages
- name: lockFileExists
value: false
- name: 'isMain'
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
# - name: 'intentSolutionPath'
# value: 'intent'
# - group: 'Intent Architect Credentials'
pr:
branches:
include:
- main
paths:
include:
- backend
trigger:
branches:
include:
- main
paths:
include:
- backend
pool:
name: Azure Pipelines
stages:
- stage: build
jobs:
- job: Job_1
displayName: Build_PD_Shesha_API
pool:
name: Azure Pipelines
vmImage: windows-latest
steps:
- checkout: self
# - task: PowerShell@2
# displayName: 'install intent cli'
# inputs:
# targetType: 'inline'
# pwsh: true
# script: dotnet tool install Intent.SoftwareFactory.CLI --global --prerelease
# - task: PowerShell@2
# displayName: 'run intent cli'
# env:
# INTENT_USER: $(intent-architect-user)
# INTENT_PASS: $(intent-architect-password)
# INTENT_SOLUTION_PATH: $(intentSolutionPath)
# inputs:
# targetType: 'inline'
# pwsh: true
# script: |
# if (($Env:INTENT_USER -Eq $null) -or ($Env:INTENT_USER -Like "`$(*")) {
# Write-Host "##vso[task.logissue type=warning;]Intent Architect Credentials not configured, see https://github.com/IntentArchitect/Intent.Modules.NET/blob/development/Modules/Intent.Modules.ContinuousIntegration.AzurePipelines/README.md#configuring-intent-architect-credentials for more information."
# Return
# }
# intent-cli ensure-no-outstanding-changes "$Env:INTENT_USER" "$Env:INTENT_PASS" "$Env:INTENT_SOLUTION_PATH"
- task: PowerShell@2
displayName: Check if Pull Request
inputs:
targetType: 'inline'
script: |
$targetBranch = ""
if ("$(Build.SourceBranch)" -like "*/pull/*")
{
$targetBranch = "$(System.PullRequest.TargetBranch)"
write-host "This is a Pull Request and the target branch is: $targetBranch"
write-host "##vso[task.setvariable variable=prTargetBranch]$targetBranch"
}
write-host "This is not a Pull Request and the target branch is set to empty string"
write-host "##vso[task.setvariable variable=prTargetBranch]''"
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: PowerShell@2
displayName: Check to establish if this pipeline was triggered from a tag
inputs:
filePath: 'ReleaseFlow.ps1'
workingDirectory: '$(System.DefaultWorkingDirectory)'
arguments: '-PipeBuildNumber "$(Build.BuildNumber)" -PipeSourceBranch "$(Build.SourceBranch)" -PipeSourceVersion "$(Build.SourceVersion)" -PipeTargetBranch "$(prTargetBranch)" -PipeBuildId "$(Build.BuildId)"'
- task: PowerShell@2
displayName: Output to console the current branch and version
inputs:
targetType: 'inline'
script: |
write-host "The current branch is: $(currentBranch)"
write-host "The current version is: $(versionNo)"
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: PowerShell@2
displayName: Create a txt file to carry the original branch name to the release pipeline
inputs:
targetType: 'inline'
script: |
$variable = '$(currentBranch)'
$variable | Out-File $(Build.ArtifactStagingDirectory)\branchName.txt
Get-Content $(Build.ArtifactStagingDirectory)\branchName.txt
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: api-info-1'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'api-info-1'
- task: PowerShell@2
displayName: 'Check for packages.lock.json'
inputs:
targetType: 'inline'
script: |
$lockFileExists = Get-ChildItem -Path "$(Build.SourcesDirectory)" -Recurse -Filter "packages.lock.json"
if ($lockFileExists.Count -gt 0) {
Write-Host "##vso[task.setvariable variable=lockFileExists]true"
} else {
Write-Host "##vso[task.setvariable variable=lockFileExists]false"
}
- task: Cache@2
displayName: Nuget Cache
inputs:
key: 'nuget | "$(Agent.OS)" | **/packages.lock.json,!**/bin/**,!**/obj/**'
restoreKeys: |
nuget | "$(Agent.OS)"
nuget
path: '$(NUGET_PACKAGES)'
cacheHitVar: 'CACHE_RESTORED'
condition: and(ne(variables.CACHE_RESTORED, true), ne(variables.lockFileExists, 'false'))
- task: NuGetCommand@2
condition: and(ne(variables.CACHE_RESTORED, true), ne(variables.lockFileExists, 'false'))
displayName: Nuget Restore
inputs:
command: 'restore'
feedsToUse: 'config'
restoreSolution: backend/src/*Host/*.csproj
nugetConfigPath: 'backend/.nuget/NuGet.Config'
- task: NuGetCommand@2
condition: eq(variables.lockFileExists, 'false')
inputs:
command: 'restore'
restoreSolution: 'backend/**/*.sln'
feedsToUse: 'config'
nugetConfigPath: 'backend/.nuget/NuGet.Config'
- task: UseDotNet@2
displayName: Use .NET Core sdk 8.x
retryCountOnTaskFailure: 3
inputs:
version: 8.x
- task: Assembly-Info-NetCore@3
displayName: 'Set Assembly Manifest Data'
inputs:
InsertAttributes: true
VersionNumber: 0.0.0-build$(Build.BuildNumber)
FileVersionNumber: 0.0.0-build$(Build.BuildNumber)
InformationalVersion: 0.0.0-build$(Build.BuildNumber)
PackageVersion: 0.0.0-build$(Build.BuildNumber)
# - task: DotNetCoreCLI@2
# displayName: dotnet Restore
# inputs:
# command: 'restore'
# projects: backend/src/*Host/*.csproj
# feedsToUse: 'config'
# nugetConfigPath: 'backend/.nuget/NuGet.Config'
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
projects: backend/src/*Host/*.csproj
arguments: --configuration $(BuildParameters.configuration)
- task: DotNetCoreCLI@2
displayName: dotnet publish
inputs:
command: publish
publishWebProjects: false
projects: backend/src/*Host/*.csproj
arguments: --configuration $(BuildParameters.configuration) --output $(build.artifactstagingdirectory) --no-build
zipAfterPublish: false
modifyOutputPath: false
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: shesha-api'
inputs:
ArtifactName: shesha-api
- task: DotNetCoreCLI@2
displayName: dotnet pack
inputs:
command: 'pack'
packagesToPack: 'backend/src/**/*.csproj'
configuration: '$(BuildParameters.configuration)'
nobuild: true
includesymbols: true
includesource: true
versioningScheme: 'byEnvVar'
versionEnvVar: 'versionNo'
- task: NuGetCommand@2
displayName: dotnet push package
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '89b3d60a-0f8d-4f9c-9231-d8ec31f33661'
publishPackageMetadata: false
allowPackageConflicts: true
condition: eq(variables['currentBranch'], 'refs/heads/main')