From 5e94c0e5ad482e375ebd56f962408f82af2b98dd Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 16 Feb 2021 11:58:04 -0800 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 1374 (#16764) * 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 --- .../pipelines/templates/steps/create-apireview.yml | 2 ++ eng/common/scripts/Package-Properties.ps1 | 1 + eng/common/scripts/Save-Package-Properties.ps1 | 14 +++++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/eng/common/pipelines/templates/steps/create-apireview.yml b/eng/common/pipelines/templates/steps/create-apireview.yml index 7628b22a1951..427bb097109e 100644 --- a/eng/common/pipelines/templates/steps/create-apireview.yml +++ b/eng/common/pipelines/templates/steps/create-apireview.yml @@ -1,6 +1,7 @@ parameters: ArtifactPath: $(Build.ArtifactStagingDirectory) Artifacts: [] + ConfigFileDir: $(Build.ArtifactStagingDirectory)/PackageInfo steps: - ${{ each artifact in parameters.Artifacts }}: @@ -13,6 +14,7 @@ steps: -APIKey $(azuresdk-apiview-apikey) -APILabel "Auto Review - $(Build.SourceVersion)" -PackageName ${{artifact.name}} + -ConfigFileDir '${{parameters.ConfigFileDir}}' pwsh: true workingDirectory: $(Pipeline.Workspace) displayName: Create API Review for ${{ artifact.name}} diff --git a/eng/common/scripts/Package-Properties.ps1 b/eng/common/scripts/Package-Properties.ps1 index f582a4a74dcf..c49b0877a029 100644 --- a/eng/common/scripts/Package-Properties.ps1 +++ b/eng/common/scripts/Package-Properties.ps1 @@ -12,6 +12,7 @@ class PackageProps [string]$Group [string]$SdkType [boolean]$IsNewSdk + [string]$ArtifactName PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory) { diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index a433b32d805a..3de89434904a 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -10,7 +10,10 @@ Param ( $allPackageProperties = Get-AllPkgProperties $serviceDirectory 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) { if ($pkg.IsNewSdk) @@ -18,7 +21,13 @@ if ($allPackageProperties) Write-Host "Package Name: $($pkg.Name)" Write-Host "Package Version: $($pkg.Version)" 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 Set-Content -Path $outputPath -Value $outputObject } @@ -31,4 +40,3 @@ else Write-Error "Package properties are not available for service directory $($serviceDirectory)" exit 1 } -