Storage/Save-PublishProfileToAzureStorage.ps1
<#
.Synopsis Function for publishing build output from Run-AlPipeline to storage account .Description Example of json file: { "publishProfiles": [ { "profile": "latest-apps", "collection": "apps", "filename": "latest", "saveFixedVersion": false }, { "profile": "release-apps", "collection": "apps", "filename": "release", "saveFixedVersion": true }, { "profile": "testapps", "collection": "testapps", "filename": "latest", "saveFixedVersion": false } ], "publishCollections": [ { "collection": "apps", "items": [ { "appNames": "SMART Helpers,SMART Core,SMART Excel Report Builder,SMART Core Localization for Ukraine,SMART Operational Reporting,SMART VAT Localization for Ukraine", "shortName": "ua" }, { "appNames": "SMART Helpers,SMART Core", "shortName": "core" } ], "destinations": [ { "appType": "RuntimePackages", "containerName": "localization-runtimes" }, { "appType": "Apps", "containerName": "localization-apps" } ] }, { "collection": "testapps", "items": [ { "appNames": "SMART Core Test Library", "shortName": "core-test-library" }, { "appNames": "SMART Core Test", "shortName": "core-tests" } ], "destinations": [ { "appType": "TestApps", "containerName": "localization-testapps" } ] } ] } .Parameter settingsFile Json file with publish settings .Parameter profileNames Comma-separated profile names from the settings file that you need to publish .Parameter StorageConnectionString A connectionstring with access to the storage account in which you want to publish artifacts (SecureString or String) #> function Save-PublishProfileToAzureStorage { Param( [Parameter(Mandatory=$true)] $appBasePath, [Parameter(Mandatory=$true)] [string] $profileNames, [Parameter(Mandatory=$true)] [string] $settingsFile, [Parameter(Mandatory=$true)] $StorageConnectionString ) $settings = Get-Content -Path $settingsFile | ConvertFrom-Json $profiles = $profileNames | splitToArray foreach ($profileName in $profiles) { $profile = $settings.publishProfiles | Where-Object { $_.profile -eq $profileName } $collection = $settings.publishCollections | Where-Object { $_.collection -eq $profile.collection } foreach ($item in $collection.items) { foreach ($destination in $collection.destinations) { $basePath = Join-Path $appBasePath $($destination.appType) $destinationPath = Join-Path $item.shortName ($profile.filename + ".zip") Write-Host "Saving $($item.appNames) to $($destination.containerName)/$destinationPath ..." Save-AppsToAzureStorage ` -appNames $($item.appNames) ` -appBasePath $basePath ` -storageConnectionString "$(ReleaseStorageConnectionString)" ` -containerName $($destination.containerName) ` -destinationPath $destinationPath if ($profile.saveFixedVersion) { $version = Get-BuildVersionFromArtifacts -appBasePath $basePath if ($version -ne "") { $destinationPath = Join-Path $item.shortName ($version + ".zip") Write-Host "Saving $($item.appNames) to $($destination.containerName)/$path ..." Save-AppsToAzureStorage ` -appNames $($item.appNames) ` -appBasePath $basePath ` -storageConnectionString "$(ReleaseStorageConnectionString)" ` -containerName $($destination.containerName) ` -destinationPath $destinationPath } } } } } } Write-Verbose "Function imported: Save-PublishProfileToAzureStorage" |