-
Notifications
You must be signed in to change notification settings - Fork 0
/
Frontend-Continues-Build-BP.yaml
158 lines (141 loc) · 6.35 KB
/
Frontend-Continues-Build-BP.yaml
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
# 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: 'isMain'
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
# - name: 'intentSolutionPath'
# value: 'intent'
# - group: 'Intent Architect Credentials'
pr:
branches:
include:
- main
paths:
include:
- adminportal
trigger:
branches:
include:
- main
paths:
include:
- adminportal
pool:
name: Azure Pipelines
stages:
- stage: build
jobs:
- job: Job_1
displayName: Build_Shesha_AdminPortal_And_Modules
pool:
vmImage: windows-latest
steps:
- 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: NodeTool@0
displayName: 'Use Node 20.11.0'
retryCountOnTaskFailure: 3
inputs:
versionSpec: 20.11.0
- task: Npm@1
displayName: 'Npm Update Version'
inputs:
command: custom
workingDir: adminportal
verbose: false
customCommand: 'version $(versionNo) --allow-same-version'
- task: npmAuthenticate@0
inputs:
workingFile: 'adminportal/.npmrc'
- task: PowerShell@2
displayName: Version Module and NPM Install, Build and Publish
inputs:
targetType: 'inline'
script: |
$PSVersionTable
write-host "The current branch is: $(currentBranch)"
write-host "The current version is: $(versionNo)"
# get the list of directories under packages
$directories = Get-ChildItem -Path ./packages -Directory
# iterate over each directory
foreach ($directory in $directories) {
Write-Host "Start of Module Processing: $($directory.Name)"
Set-Location -Path $directory.FullName
Write-Host "Set Module Version"
# npm version $(versionNo) --allow-same-version --no-git-tag-version
$filePath = "package.json"
$Jsonfile = Get-Content $filePath -raw | ConvertFrom-Json
$Jsonfile.name = "@shesha-io/shesha-tutorial"
$Jsonfile.version = "$(versionNo)"
ConvertTo-Json $Jsonfile -Depth 5 | Set-Content $filePath
# output the contents of the updated file
Get-Content $filePath
Write-Host "End of Module Configuration File Output: $($directory.Name)"
}
# Write-Host "Go back to AdminPortal Folder"
Set-Location -Path $(System.DefaultWorkingDirectory)/adminportal
# Write-Host "Set AdminPortal Version"
# npm version $(versionNo) --allow-same-version --no-git-tag-version
# npm steps on root adminportal
Write-Host "Install dependencies"
npm install --legacy-peer-deps
Write-Host "Build project"
npm run build
if ("$(currentBranch)" -like "*/main"){
Write-Host "Publish library"
npm publish --workspace=*
}
workingDirectory: 'adminportal'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: 'adminportal'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/adminportal.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: shesha-adminportal'
inputs:
ArtifactName: adminportal