-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathexport-powerapps.yml
187 lines (182 loc) · 8.66 KB
/
export-powerapps.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
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
name: CI/CD for Canvas Apps
trigger: none
resources:
repositories:
- repository: poc_alm_powerapps
type: git
name: My Work/poc-alm-powerapps
ref: refs/heads/main
stages:
- stage: export_solution
displayName: Export Solution
variables:
SolutionName: 'ALMDemo'
SolutionOutput: 'ALMDemo.zip'
jobs:
- job: export_solution
displayName: Export Solution
pool:
vmImage: vs2017-win2016
steps:
- checkout: poc_alm_powerapps
persistCredentials: True
- task: PowerPlatformToolInstaller@0
displayName: 'Power Platform Tool Installer '
- task: PowerPlatformWhoAmi@0
displayName: 'Power Platform WhoAmI '
inputs:
authenticationType: 'PowerPlatformSPN'
PowerPlatformSPN: 'CS Apps Dev'
- task: PowerPlatformExportSolution@0
displayName: 'Power Platform Export Unmanaged Solution '
inputs:
authenticationType: 'PowerPlatformSPN'
PowerPlatformSPN: 'CS Apps Dev'
SolutionName: '$(SolutionName)'
SolutionOutputFile: '$(Build.ArtifactStagingDirectory)/$(SolutionName).zip'
AsyncOperation: true
MaxAsyncWaitTime: '240'
- task: PowerPlatformChecker@0
displayName: 'Power Platform Checker '
inputs:
PowerPlatformSPN: 'CS Apps Dev'
FilesToAnalyze: '$(Build.ArtifactStagingDirectory)/$(SolutionName).zip'
RuleSet: '0ad12346-e108-40b8-a956-9a8f95ea18c9'
ArtifactDestinationName: 'AppsCheckerAnalysisLogs'
- task: PowerPlatformUnpackSolution@0
displayName: 'Power Platform Unpack Solution '
inputs:
SolutionInputFile: $(Build.ArtifactStagingDirectory)/$(SolutionName).zip
SolutionTargetFolder: $(Build.SourcesDirectory)\$(SolutionName)
- task: CmdLine@2
displayName: Commit Solution
inputs:
script: |
echo commit all changes
git config user.email "powerapps@microsoft.com"
git config user.name "Automatic Build"
git checkout main
git add --all
git commit -m "export solution"
echo push code to new repo
git -c http.extraheader="AUTHORIZATION: Bearer $(System.AccessToken)" push origin main
- task: PowerPlatformExportSolution@0
displayName: Power Platform Export Managed Solution
inputs:
authenticationType: 'PowerPlatformSPN'
PowerPlatformSPN: 'CS Apps Dev'
SolutionName: '$(SolutionName)'
SolutionOutputFile: '$(Build.ArtifactStagingDirectory)/$(SolutionName)_managed.zip'
Managed: true
AsyncOperation: true
MaxAsyncWaitTime: '240'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
- stage: deploy_solution
displayName: Deploy Solution
dependsOn: export_solution
jobs:
- deployment: deploy_prod
displayName: Deploy to Prod
environment: PowerApps_Prod
pool:
vmImage: vs2017-win2016
variables:
0.DatasetName: $(SharepointURL)
SolutionName: 'ALMDemo'
TableName: '$(SharepointTableID)'
strategy:
runOnce:
deploy:
steps:
- task: UniversalPackages@0
inputs:
command: 'download'
downloadDirectory: '$(System.DefaultWorkingDirectory)/_powerapps-language-tooling'
feedsToUse: 'internal'
vstsFeed: 'bc4526fc-921b-4180-b4d7-4c1eb21fcdee/76845d6b-95ee-4c43-99d1-df8d528da657'
vstsFeedPackage: '388360c4-c4dd-4c2c-8fe2-bb906351865c'
vstsPackageVersion: '0.0.3'
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.DefaultWorkingDirectory)'
- task: PowerPlatformToolInstaller@0
inputs:
DefaultVersion: true
- task: PowerPlatformUnpackSolution@0
inputs:
SolutionInputFile: '$(System.DefaultWorkingDirectory)/drop/$(SolutionName)_managed.zip'
SolutionTargetFolder: '$(Agent.TempDirectory)/solutions/$(SolutionName)'
SolutionType: 'Managed'
- task: CmdLine@2
displayName: Unpack MSAPP
inputs:
script: 'PASopa.exe -unpack $(Agent.TempDirectory)\solutions\$(SolutionName)\CanvasApps\apps_almdemo_9e98b_DocumentUri.msapp $(Agent.TempDirectory)\solutions\src\$(SolutionName)'
workingDirectory: '$(System.DefaultWorkingDirectory)/_powerapps-language-tooling'
- task: FileTransform@1
displayName: Update Data Sources
inputs:
folderPath: '$(Agent.TempDirectory)\solutions\src\$(SolutionName)'
fileType: 'json'
targetFiles: '**/DataSources/Work*progress*tracker.json'
- task: PowerShell@2
displayName: Update Connections
inputs:
targetType: 'inline'
script: |
$connectionsFile = "$(Agent.TempDirectory)\solutions\src\$(SolutionName)\Connections\Connections.json"
$connections = Get-Content -Path $connectionsFile | ConvertFrom-Json
$connections.'0bb507df-2b7f-4f46-ba1d-95edf64001b9'.datasets = @{
'$(SharepointURL)'= @{
dataSources = @{
'Work progress tracker' = @{
tableName = "$(SharepointTableID)"
}
}
}
}
$connections | ConvertTo-Json -Depth 10 | Set-Content $connectionsFile
- task: FileTransform@1
displayName: Update Table Definitions
inputs:
folderPath: '$(Agent.TempDirectory)\solutions\src\$(SolutionName)'
fileType: 'json'
targetFiles: '**/pkgs/TableDefinitions/Work*progress*tracker.json'
- task: PowerShell@2
displayName: Update Table Metadata Definitions
inputs:
targetType: 'inline'
script: |
$definitionsFile = "$(Agent.TempDirectory)\solutions\src\$(SolutionName)\pkgs\TableDefinitions\Work progress tracker.json"
$definitions = Get-Content -Path $definitionsFile | ConvertFrom-Json
$metadata = $definitions.DataEntityMetadataJson.'$(DevSharepointTableID)'
$metadata = $metadata -replace "$(DevSharepointTableID)", "$(SharepointTableID)"
$metadata = $metadata -replace "$(DevSharepointURL)", "$(SharepointURL)"
$definitions.DataEntityMetadataJson = @{
'$(SharepointTableID)' = $metadata
}
$definitions | ConvertTo-Json -Depth 10 | Set-Content $definitionsFile
- task: CmdLine@2
displayName: Pack MSAPP
inputs:
script: 'PASopa.exe -pack $(Agent.TempDirectory)\solutions\$(SolutionName)\CanvasApps\apps_almdemo_9e98b_DocumentUri.msapp $(Agent.TempDirectory)\solutions\src\$(SolutionName)'
workingDirectory: '$(System.DefaultWorkingDirectory)/_powerapps-language-tooling'
- task: PowerPlatformPackSolution@0
displayName: Power Platform Pack Solution
inputs:
SolutionSourceFolder: '$(Agent.TempDirectory)/solutions/$(SolutionName)'
SolutionOutputFile: '$(Agent.TempDirectory)/solutions/$(SolutionName)_managed.zip'
SolutionType: 'Managed'
- task: PowerPlatformImportSolution@0
displayName: Power Platform Import Solution
inputs:
authenticationType: 'PowerPlatformSPN'
PowerPlatformSPN: 'CS Apps Prod'
SolutionInputFile: '$(Agent.TempDirectory)/solutions/$(SolutionName)_managed.zip'
AsyncOperation: true
MaxAsyncWaitTime: '240'
OverwriteUnmanagedCustomizations: true
ConvertToManaged: true