DevOpsHandling/Publish-DevOpsArtifactsToFeed.ps1
function Publish-DevOpsArtifactsToFeed { Param( [Parameter(Mandatory=$false)] [string]$devOpsOrganization = "", [Parameter(Mandatory=$false)] [string]$devOpsFeed = "", [Parameter(Mandatory=$false)] [string]$devOpsArtifact = "", [Parameter(Mandatory=$false)] [string]$devOpsToken = "", [Parameter(Mandatory=$true)] [string]$sourcePath, [Parameter(Mandatory=$false)] [string]$version = "" ) if ($devOpsOrganization -eq "") { $devOpsOrganization = Get-EnvironmentKeyValue -KeyName "Organization" } if ($devOpsToken -eq "") { $devOpsToken = Get-EnvironmentKeyValue -KeyName "token" } if (!(Test-Path $destination)) { New-Item -Path $destination -ItemType Directory | Out-Null } if ($devOpsArtifact -eq "") { $devOpsArtifact = (((Get-AppKeyValue -KeyName 'name') -replace ' ', '_').ToLower()) } if ($version -eq "") { $version = ((Get-AppKeyValue -KeyName 'version') -replace '(.*)\.(.*)','$1') } if ($devOpsFeed -eq "") { $dependencies = Get-EnvironmentKeyValue -KeyName "dependencies" if ($null -ne $dependencies) { $devOpsFeed = $dependencies[0].devOpsFeed } } # publishing app Write-Host "Publishing $($devOpsArtifact)_app" foreach ($app in (Get-ChildItem (Join-Path $sourcePath "app") -filter "*.app")) { $output = az artifacts universal publish --organization ("https://dev.azure.com/" + $devOpsOrganization) --feed "$devOpsFeed" --name "$($devOpsArtifact)_app" --version "$version" --path $app.FullName if (!$output) { throw "Could not publish package $($devOpsArtifact)_app to $devOpsOrganization feed $devOpsFeed" } } # publishing runtime app Write-Host "Publishing $($devOpsArtifact)_runtimeapp" foreach ($app in (Get-ChildItem (Join-Path $sourcePath "runtime") -Filter "*.app")) { $output = az artifacts universal publish --organization ("https://dev.azure.com/" + $devOpsOrganization) --feed "$devOpsFeed" --name "$($devOpsArtifact)_runtime" --version "$version" --path $app.FullName if (!$output) { throw "Could not publish package $($devOpsArtifact)_runtime to $devOpsOrganization feed $devOpsFeed" } } # publishing tests app Write-Host "Publishing $($devOpsArtifact)_testapp" foreach ($app in (Get-ChildItem (Join-Path $sourcePath "tests") -Filter "*.app")) { $output = az artifacts universal publish --organization ("https://dev.azure.com/" + $devOpsOrganization) --feed "$devOpsFeed" --name "$($devOpsArtifact)_tests" --version "$version" --path $app.FullName if (!$output) { throw "Could not publish package $($devOpsArtifact)_tests to $devOpsOrganization feed $devOpsFeed" } } } Export-ModuleMember Publish-DevOpsArtifactsToFeed |