Sync eng/common directory with azure-sdk-tools for PR 1374 (#1686)

* Create package property file using artifact name

* Add option to pass config file dir

* Set default config file directory to avoid script execution failure

Co-authored-by: praveenkuttappan <prmarott@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-02-16 11:57:56 -08:00 committed by GitHub
parent b68a20e3d2
commit f929894274
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View File

@ -1,6 +1,7 @@
parameters: parameters:
ArtifactPath: $(Build.ArtifactStagingDirectory) ArtifactPath: $(Build.ArtifactStagingDirectory)
Artifacts: [] Artifacts: []
ConfigFileDir: $(Build.ArtifactStagingDirectory)/PackageInfo
steps: steps:
- ${{ each artifact in parameters.Artifacts }}: - ${{ each artifact in parameters.Artifacts }}:
@ -13,6 +14,7 @@ steps:
-APIKey $(azuresdk-apiview-apikey) -APIKey $(azuresdk-apiview-apikey)
-APILabel "Auto Review - $(Build.SourceVersion)" -APILabel "Auto Review - $(Build.SourceVersion)"
-PackageName ${{artifact.name}} -PackageName ${{artifact.name}}
-ConfigFileDir '${{parameters.ConfigFileDir}}'
pwsh: true pwsh: true
workingDirectory: $(Pipeline.Workspace) workingDirectory: $(Pipeline.Workspace)
displayName: Create API Review for ${{ artifact.name}} displayName: Create API Review for ${{ artifact.name}}

View File

@ -12,6 +12,7 @@ class PackageProps
[string]$Group [string]$Group
[string]$SdkType [string]$SdkType
[boolean]$IsNewSdk [boolean]$IsNewSdk
[string]$ArtifactName
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory) PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory)
{ {

View File

@ -10,7 +10,10 @@ Param (
$allPackageProperties = Get-AllPkgProperties $serviceDirectory $allPackageProperties = Get-AllPkgProperties $serviceDirectory
if ($allPackageProperties) if ($allPackageProperties)
{ {
New-Item -ItemType Directory -Force -Path $outDirectory if (-not (Test-Path -Path $outDirectory))
{
New-Item -ItemType Directory -Force -Path $outDirectory
}
foreach($pkg in $allPackageProperties) foreach($pkg in $allPackageProperties)
{ {
if ($pkg.IsNewSdk) if ($pkg.IsNewSdk)
@ -18,7 +21,13 @@ if ($allPackageProperties)
Write-Host "Package Name: $($pkg.Name)" Write-Host "Package Name: $($pkg.Name)"
Write-Host "Package Version: $($pkg.Version)" Write-Host "Package Version: $($pkg.Version)"
Write-Host "Package SDK Type: $($pkg.SdkType)" Write-Host "Package SDK Type: $($pkg.SdkType)"
$outputPath = Join-Path -Path $outDirectory ($pkg.Name + ".json") Write-Host "Artifact Name: $($pkg.ArtifactName)"
$configFilePrefix = $pkg.Name
if ($pkg.ArtifactName)
{
$configFilePrefix = $pkg.ArtifactName
}
$outputPath = Join-Path -Path $outDirectory "$configFilePrefix.json"
$outputObject = $pkg | ConvertTo-Json $outputObject = $pkg | ConvertTo-Json
Set-Content -Path $outputPath -Value $outputObject Set-Content -Path $outputPath -Value $outputObject
} }
@ -31,4 +40,3 @@ else
Write-Error "Package properties are not available for service directory $($serviceDirectory)" Write-Error "Package properties are not available for service directory $($serviceDirectory)"
exit 1 exit 1
} }