183
183
Information about which product built the app. Will be stamped into the app manifest.
184
184
. Parameter BuildUrl
185
185
The URL for the build job, which built the app. Will be stamped into the app manifest.
186
+ . Parameter PipelineInitialize
187
+ Override for Pipeline Initialize
188
+ . Parameter PipelineFinalize
189
+ Override for Pipeline Finalize
186
190
. Parameter DockerPull
187
191
Override function parameter for docker pull
188
192
. Parameter NewBcContainer
193
197
Override function parameter for Import-TestToolkitToBcContainer
194
198
. Parameter CompileAppInBcContainer
195
199
Override function parameter for Compile-AppInBcContainer
196
- . Parameter CompileAppWithBcCompilerFolder
200
+ . Parameter CompileAppWithBcCompilerFolder
197
201
Override function parameter for Compile-AppWithBcCompilerFolder
198
202
. Parameter PreCompileApp
199
203
Custom script to run before compiling an app.
@@ -363,6 +367,7 @@ Param(
363
367
[string ] $sourceCommit = ' ' ,
364
368
[string ] $buildBy = " BcContainerHelper,$BcContainerHelperVersion " ,
365
369
[string ] $buildUrl = ' ' ,
370
+ [scriptblock ] $PipelineInitialize ,
366
371
[scriptblock ] $DockerPull ,
367
372
[scriptblock ] $NewBcContainer ,
368
373
[scriptblock ] $SetBcContainerKeyVaultAadAppAndCertificate ,
@@ -383,7 +388,8 @@ Param(
383
388
[scriptblock ] $RemoveBcContainer ,
384
389
[scriptblock ] $GetBestGenericImageName ,
385
390
[scriptblock ] $GetBcContainerEventLog ,
386
- [scriptblock ] $InstallMissingDependencies
391
+ [scriptblock ] $InstallMissingDependencies ,
392
+ [scriptblock ] $PipelineFinalize
387
393
)
388
394
389
395
function CheckRelativePath ([string ] $baseFolder , [string ] $sharedFolder , $path , $name ) {
@@ -475,6 +481,10 @@ function GetInstalledAppIds {
475
481
$telemetryScope = InitTelemetryScope - name $MyInvocation.InvocationName - parameterValues $PSBoundParameters - includeParameters @ ()
476
482
try {
477
483
484
+ if ($PipelineInitialize ) {
485
+ Invoke-Command - ScriptBlock $PipelineInitialize
486
+ }
487
+
478
488
$warningsToShow = @ ()
479
489
480
490
if (! $baseFolder -or ! (Test-Path $baseFolder - PathType Container)) {
@@ -554,13 +564,19 @@ if ($bcAuthContext) {
554
564
Write-Host - ForegroundColor Yellow " Uninstalling removed apps from online environments are not supported"
555
565
$uninstallRemovedApps = $false
556
566
}
557
- $bcAuthContext = Renew- BcAuthContext - bcAuthContext $bcAuthContext
558
- $bcEnvironment = Get-BcEnvironments - bcAuthContext $bcAuthContext | Where-Object { $_.name -eq $environment -and $_.type -eq " Sandbox" }
559
- if (! ($bcEnvironment )) {
560
- throw " Environment $environment doesn't exist in the current context or it is not a Sandbox environment."
567
+ if ($environment -notlike (' https://*' )) {
568
+ $bcAuthContext = Renew- BcAuthContext - bcAuthContext $bcAuthContext
569
+ $bcEnvironment = Get-BcEnvironments - bcAuthContext $bcAuthContext | Where-Object { $_.name -eq $environment -and $_.type -eq " Sandbox" }
570
+ if (! ($bcEnvironment )) {
571
+ throw " Environment $environment doesn't exist in the current context or it is not a Sandbox environment."
572
+ }
573
+ $parameters = @ {
574
+ bcAuthContext = $bcAuthContext
575
+ environment = $environment
576
+ }
577
+ $bcBaseApp = Get-BcPublishedApps @Parameters | Where-Object { $_.Name -eq " Base Application" -and $_.state -eq " installed" }
578
+ $artifactUrl = Get-BCArtifactUrl - type Sandbox - country $bcEnvironment.countryCode - version $bcBaseApp.Version - select Closest
561
579
}
562
- $bcBaseApp = Get-BcPublishedApps - bcAuthContext $bcauthcontext - environment $environment | Where-Object { $_.Name -eq " Base Application" -and $_.state -eq " installed" }
563
- $artifactUrl = Get-BCArtifactUrl - type Sandbox - country $bcEnvironment.countryCode - version $bcBaseApp.Version - select Closest
564
580
$filesOnly = $true
565
581
}
566
582
@@ -748,14 +764,16 @@ Write-Host -ForegroundColor Yellow "Custom CodeCops"
748
764
if ($customCodeCops ) { $customCodeCops | ForEach-Object { Write-Host " - $_ " } } else { Write-Host " - None" }
749
765
750
766
$vsixFile = DetermineVsixFile - vsixFile $vsixFile
751
-
752
767
$compilerFolder = ' '
768
+ $createContainer = $true
753
769
754
770
if ($useCompilerFolder ) {
755
771
# We are using CompilerFolder, no need for a filesOnly Container
756
772
# If we are to create a container, it is for publishing and testing
757
773
$filesOnly = $false
758
774
$updateLaunchJson = ' '
775
+ $createContainer = ! ($doNotPublishApps -or ($bcAuthContext -and $environment ))
776
+ if (! $createContainer ) { $containerName = ' ' }
759
777
}
760
778
elseif ($doNotPublishApps ) {
761
779
# We are not using CompilerFolder, but we are not publishing apps either
@@ -908,7 +926,7 @@ $signApps = ($codeSignCertPfxFile -ne "")
908
926
909
927
Measure-Command {
910
928
911
- if ( $artifactUrl -and ! $reUseContainer -and ! $doNotPublishApps -and ! $filesOnly ) {
929
+ if ( $artifactUrl -and ! $reUseContainer -and $createContainer ) {
912
930
if ($gitHubActions ) { Write-Host " ::group::Pulling generic image" }
913
931
Measure-Command {
914
932
Write-Host - ForegroundColor Yellow @'
@@ -948,19 +966,36 @@ try {
948
966
$testCountry = $_.Trim ()
949
967
$testToolkitInstalled = $false
950
968
951
- if ($gitHubActions ) { Write-Host " ::group::Creating container" }
952
- Write-Host - ForegroundColor Yellow @'
969
+ if ($useCompilerFolder ) {
970
+ if ($gitHubActions ) { Write-Host " ::group::Creating CompilerFolder" }
971
+ Write-Host - ForegroundColor Yellow @'
972
+
973
+ _____ _ _ _____ _ _ ______ _ _
974
+ / ____| | | (_) / ____| (_) | | ____| | | | |
975
+ | | _ __ ___ __ _| |_ _ _ __ __ _ | | ___ _ __ ___ _ __ _| | ___ _ __| |__ ___ | | __| | ___ _ __
976
+ | | | '__/ _ \/ _` | __| | '_ \ / _` | | | / _ \| '_ ` _ \| '_ \| | |/ _ \ '__| __/ _ \| |/ _` |/ _ \ '__|
977
+ | |____| | | __/ (_| | |_| | | | | (_| | | |___| (_) | | | | | | |_) | | | __/ | | | | (_) | | (_| | __/ |
978
+ \_____|_| \___|\__,_|\__|_|_| |_|\__, | \_____\___/|_| |_| |_| .__/|_|_|\___|_| |_| \___/|_|\__,_|\___|_|
979
+ __/ | | |
980
+ |___/ |_|
953
981
954
- _____ _ _ _ _
955
- / ____| | | (_) | | (_)
956
- | | _ __ ___ __ _| |_ _ _ __ __ _ ___ ___ _ __ | |_ __ _ _ _ __ ___ _ __
957
- | | | '__/ _ \/ _` | __| | '_ \ / _` | / __/ _ \| '_ \| __/ _` | | '_ \ / _ \ '__|
958
- | |____| | | __/ (_| | |_| | | | | (_| | | (__ (_) | | | | |_ (_| | | | | | __/ |
959
- \_____|_| \___|\__,_|\__|_|_| |_|\__, | \___\___/|_| |_|\__\__,_|_|_| |_|\___|_|
982
+ '@
983
+ }
984
+ else {
985
+ if ($gitHubActions ) { Write-Host " ::group::Creating container" }
986
+ Write-Host - ForegroundColor Yellow @'
987
+
988
+ _____ _ _ _____ _ _
989
+ / ____| | | (_) / ____| | | (_)
990
+ | | _ __ ___ __ _| |_ _ _ __ __ _ | | ___ _ __ | |_ __ _ _ _ __ ___ _ __
991
+ | | | '__/ _ \/ _` | __| | '_ \ / _` | | | / _ \| '_ \| __/ _` | | '_ \ / _ \ '__|
992
+ | |____| | | __/ (_| | |_| | | | | (_| | | |___| (_) | | | | || (_| | | | | | __/ |
993
+ \_____|_| \___|\__,_|\__|_|_| |_|\__, | \_____\___/|_| |_|\__\__,_|_|_| |_|\___|_|
960
994
__/ |
961
995
|___/
962
996
963
997
'@
998
+ }
964
999
965
1000
Measure-Command {
966
1001
@@ -983,7 +1018,7 @@ Measure-Command {
983
1018
- containerName $containerName
984
1019
Write-Host " CompilerFolder $compilerFolder created"
985
1020
}
986
- if ($filesOnly -or ! $doNotPublishApps ) {
1021
+ if ($createContainer -and ( $ filesOnly -or ! $doNotPublishApps ) ) {
987
1022
# If we are going to build using a filesOnly container or we are going to publish apps, we need a container
988
1023
if (Test-BcContainer - containerName $containerName ) {
989
1024
if ($bcAuthContext ) {
@@ -1035,7 +1070,7 @@ Measure-Command {
1035
1070
}
1036
1071
Invoke-Command - ScriptBlock $NewBcContainer - ArgumentList $Parameters
1037
1072
1038
- if (-not $bcAuthContext ) {
1073
+ if ($createContainer -and -not $bcAuthContext ) {
1039
1074
if ($keyVaultCertPfxFile -and $KeyVaultClientId -and $keyVaultCertPfxPassword ) {
1040
1075
$Parameters = @ {
1041
1076
" containerName" = $containerName
@@ -1329,6 +1364,7 @@ Measure-Command {
1329
1364
Write-Host - ForegroundColor Yellow " Importing Test Toolkit for additional country $testCountry "
1330
1365
$Parameters = @ {
1331
1366
" containerName" = $containerName
1367
+ " compilerFolder" = $compilerFolder
1332
1368
" includeTestLibrariesOnly" = $installTestLibraries
1333
1369
" includeTestFrameworkOnly" = ! $installTestLibraries -and ($installTestFramework -or $installPerformanceToolkit )
1334
1370
" includeTestRunnerOnly" = ! $installTestLibraries -and ! $installTestFramework -and ($installTestRunner -or $installPerformanceToolkit )
@@ -1508,6 +1544,7 @@ Measure-Command {
1508
1544
$measureText = " , test apps and importing test toolkit"
1509
1545
$Parameters = @ {
1510
1546
" containerName" = $containerName
1547
+ " compilerFolder" = $compilerFolder
1511
1548
" includeTestLibrariesOnly" = $installTestLibraries
1512
1549
" includeTestFrameworkOnly" = ! $installTestLibraries -and ($installTestFramework -or $installPerformanceToolkit )
1513
1550
" includeTestRunnerOnly" = ! $installTestLibraries -and ! $installTestFramework -and ($installTestRunner -or $installPerformanceToolkit )
@@ -1654,7 +1691,7 @@ Write-Host -ForegroundColor Yellow @'
1654
1691
$Parameters = @ { }
1655
1692
$CopParameters = @ { }
1656
1693
1657
- if ($bcAuthContext ) {
1694
+ if ($bcAuthContext -and ! $useCompilerFolder ) {
1658
1695
$Parameters += @ {
1659
1696
" bcAuthContext" = $bcAuthContext
1660
1697
" environment" = $environment
@@ -2433,6 +2470,7 @@ $testAppIds.Keys | ForEach-Object {
2433
2470
}
2434
2471
$Parameters = @ {
2435
2472
" containerName" = $containerName
2473
+ " compilerFolder" = $compilerFolder
2436
2474
" tenant" = $tenant
2437
2475
" credential" = $credential
2438
2476
" companyName" = $companyName
@@ -2461,6 +2499,7 @@ $testAppIds.Keys | ForEach-Object {
2461
2499
$Parameters += @ {
2462
2500
" bcAuthContext" = $bcAuthContext
2463
2501
" environment" = $environment
2502
+ " ConnectFromHost" = ! $createContainer
2464
2503
}
2465
2504
}
2466
2505
@@ -2615,7 +2654,11 @@ finally {
2615
2654
$progressPreference = $prevProgressPreference
2616
2655
}
2617
2656
2618
- if (! $keepContainer ) {
2657
+ if ($useCompilerFolder -and $compilerFolder ) {
2658
+ Remove-BcCompilerFolder - compilerFolder $compilerFolder
2659
+ }
2660
+
2661
+ if ($createContainer -and ! $keepContainer ) {
2619
2662
if ($gitHubActions ) { Write-Host " ::group::Removing container" }
2620
2663
if (! ($err )) {
2621
2664
Write-Host - ForegroundColor Yellow @'
@@ -2631,9 +2674,6 @@ Write-Host -ForegroundColor Yellow @'
2631
2674
}
2632
2675
Measure-Command {
2633
2676
2634
- if ($useCompilerFolder -and $compilerFolder ) {
2635
- Remove-BcCompilerFolder - compilerFolder $compilerFolder
2636
- }
2637
2677
if (! $doNotPublishApps ) {
2638
2678
if (! $filesOnly -and $containerEventLogFile ) {
2639
2679
try {
@@ -2667,6 +2707,10 @@ if ($err) {
2667
2707
2668
2708
} | ForEach-Object { Write-Host - ForegroundColor Yellow " `n AL Pipeline finished in $ ( [int ]$_.TotalSeconds ) seconds" }
2669
2709
2710
+ if ($PipelineFinalize ) {
2711
+ Invoke-Command - ScriptBlock $PipelineFinalize
2712
+ }
2713
+
2670
2714
}
2671
2715
catch {
2672
2716
TrackException - telemetryScope $telemetryScope - errorRecord $_
0 commit comments