Skip to content

Commit 9e9170b

Browse files
inner loop, add update-meta-data script (#48014)
* inner loop, add update-meta-data script * remove ci.yaml updates * Add CI.yml provisioning and update support Adds CI.yml update as Step 4 in the metadata update script, ported from the Python implementation in eng/automation/utils.py. Supported cases: - Create new ci.yml from template for brand-new services - Add artifact entry to existing ci.yml (with/without release params) - Rename ci.yml to ci.data.yml when SDKType=data and create new ci.yml - Skip when module already exists (idempotent) - Management-plane packages get default: false for release param - Data-plane packages get default: true for release param Fixes Azure/azure-sdk-tools#13808 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * resolve comments * Fail metadata update for unsupported SDK types Add groupId validation to reject unsupported SDK types (e.g., com.azure.spring). Only com.azure and com.azure.resourcemanager are supported. Uses LogError with the package path for clear diagnostics before exiting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c113811 commit 9e9170b

4 files changed

Lines changed: 1848 additions & 0 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
<#
5+
.SYNOPSIS
6+
Updates parent-level and root-level pom.xml files, and ci.yml for a Java SDK package.
7+
8+
.DESCRIPTION
9+
This script handles two cases:
10+
Case 1 - Service exists, new resourcemanager package:
11+
- Skips root pom (service already listed)
12+
- Updates service-level pom.xml with new module
13+
- Updates ci.yml with new artifact entry
14+
Case 2 - Brand new service:
15+
- Updates root pom.xml with new service module
16+
- Creates service-level pom.xml from template
17+
- Creates ci.yml from template with new artifact entry
18+
19+
.PARAMETER PackagePath
20+
Absolute path to the root folder of the local SDK project (containing pom.xml).
21+
22+
.PARAMETER SdkRepoPath
23+
Absolute path to the root folder of the local SDK repository.
24+
25+
.EXAMPLE
26+
.\Automation-Sdk-UpdateMetadata.ps1 -PackagePath "C:\repos\azure-sdk-for-java\sdk\network\azure-resourcemanager-network" -SdkRepoPath "C:\repos\azure-sdk-for-java"
27+
#>
28+
29+
param(
30+
[Parameter(Mandatory = $true)]
31+
[ValidateScript({Test-Path $_})]
32+
[string]$PackagePath,
33+
34+
[Parameter(Mandatory = $true)]
35+
[ValidateScript({Test-Path $_})]
36+
[string]$SdkRepoPath
37+
)
38+
39+
$ErrorActionPreference = "Stop"
40+
41+
# Import common scripts for logging functions
42+
$commonScriptPath = Join-Path $PSScriptRoot ".." "common" "scripts" "common.ps1"
43+
. $commonScriptPath
44+
45+
# Import metadata helper functions
46+
$helperPath = Join-Path $PSScriptRoot "helpers" "Metadata-Helpers.ps1"
47+
. $helperPath
48+
49+
try {
50+
LogInfo "========================================"
51+
LogInfo "Azure SDK Metadata Update Tool"
52+
LogInfo "========================================"
53+
LogInfo ""
54+
55+
LogInfo "Step 1: Deriving service and module from package path..."
56+
$pathInfo = Get-ServiceAndModuleFromPath -PackagePath $PackagePath -SdkRepoPath $SdkRepoPath
57+
$service = $pathInfo.Service
58+
$module = $pathInfo.Module
59+
LogInfo " Service: $service"
60+
LogInfo " Module: $module"
61+
LogInfo ""
62+
63+
LogInfo "Step 2: Updating root pom.xml..."
64+
Update-RootPom -SdkRepoPath $SdkRepoPath -Service $service
65+
LogInfo ""
66+
67+
LogInfo "Step 3: Updating service-level pom.xml..."
68+
Update-ServicePom -SdkRepoPath $SdkRepoPath -Service $service -Module $module
69+
LogInfo ""
70+
71+
LogInfo "Step 4: Updating ci.yml..."
72+
$packagePomPath = Join-Path $PackagePath "pom.xml"
73+
if (Test-Path $packagePomPath) {
74+
$groupId = Get-GroupIdFromPom -PomPath $packagePomPath
75+
LogInfo " GroupId: $groupId"
76+
77+
$supportedGroupIds = @("com.azure", "com.azure.resourcemanager")
78+
if ($groupId -notin $supportedGroupIds) {
79+
LogError "Unsupported SDK type with groupId '$groupId' at '$PackagePath'. This script only supports: $($supportedGroupIds -join ', ')."
80+
exit 1
81+
}
82+
83+
Update-CiYml -SdkRepoPath $SdkRepoPath -Service $service -Module $module -GroupId $groupId
84+
}
85+
else {
86+
LogError "No pom.xml found at '$packagePomPath'. Cannot determine groupId for ci.yml update."
87+
}
88+
LogInfo ""
89+
90+
LogInfo "✅ Metadata updated successfully!"
91+
exit 0
92+
}
93+
catch {
94+
LogError "An error occurred: $_"
95+
LogError "Stack trace: $($_.ScriptStackTrace)"
96+
exit 1
97+
}

0 commit comments

Comments
 (0)