From a4fdada4b9d482d75db98ba29a95ad01875f2d71 Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Sat, 18 Oct 2025 10:59:27 -0700
Subject: [PATCH 01/15] ci: fix broken OpenAPI generation
---
.../generation-templates/capture-openapi.yml | 58 +++++++++++--------
scripts/git-push-cleanmetadata.ps1 | 52 +++++++++++++----
2 files changed, 74 insertions(+), 36 deletions(-)
diff --git a/.azure-pipelines/generation-templates/capture-openapi.yml b/.azure-pipelines/generation-templates/capture-openapi.yml
index 617931c8d..1d546d54b 100644
--- a/.azure-pipelines/generation-templates/capture-openapi.yml
+++ b/.azure-pipelines/generation-templates/capture-openapi.yml
@@ -1,3 +1,4 @@
+# capture-openapi.yml
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
# The following template creates multiple artifacts from a matrix, this is the intended behavior to follow the same workflow before the governance migration
@@ -21,6 +22,7 @@ jobs:
persistCredentials: true
- template: /.azure-pipelines/generation-templates/checkout-metadata.yml@self
+
- pwsh: |
$dirPath = "./conversion-settings"
$endpoint = "${{ parameters.endpoint }}"
@@ -37,8 +39,10 @@ jobs:
Write-Host "##vso[task.setvariable variable=targets;isOutput=true]$json"
name: setTargets
workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
+
- script: echo $(setTargets.targets)
displayName: "Print settings"
+
- job: convert_openapi
dependsOn: get_conversion_settings
displayName: Convert
@@ -58,28 +62,33 @@ jobs:
persistCredentials: true
- template: /.azure-pipelines/generation-templates/checkout-metadata.yml@self
-
# required for the hidi to run
- template: /.azure-pipelines/generation-templates/use-dotnet-sdk.yml@self
parameters:
version: '8.x'
-
-# required for the hidi installation validation
+ displayName: use dotnet sdk 8.x
+ # required for the hidi installation validation
- template: /.azure-pipelines/generation-templates/use-dotnet-sdk.yml@self
parameters:
version: '9.x'
+ displayName: use dotnet sdk 9.x
- pwsh: dotnet tool install --global Microsoft.OpenApi.Hidi --version 1.6.24
displayName: install hidi
- pwsh: |
- git fetch origin master
- git switch master
+ git fetch origin master | Write-Host -ForegroundColor Yellow
+ git switch master | Write-Host -ForegroundColor Yellow
displayName: ensure the generation happens from master latest
workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
- - pwsh: '$(scriptsDirectory)/generate-open-api.ps1 -endpointVersion ${{ parameters.endpoint }} -settings "$(conversionSettingsDirectory)/$(File)" -platformName "$(Name)"'
- displayName: 'update ${{ parameters.endpoint }} open API description'
+ - pwsh: |
+ Write-Host "`nGet status before generation:" -ForegroundColor Green
+ git status | Write-Host -ForegroundColor Yellow
+ $(scriptsDirectory)/generate-open-api.ps1 -endpointVersion ${{ parameters.endpoint }} -settings "$(conversionSettingsDirectory)/$(File)" -platformName "$(Name)"
+ Write-Host "`nGet status after generation:" -ForegroundColor Green
+ git status | Write-Host -ForegroundColor Yellow
+ displayName: 'generate ${{ parameters.endpoint }} open API description'
workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
# publish metadata as an artifact
@@ -88,16 +97,16 @@ jobs:
sourceFolder: ${{ parameters.outputPath }}
contents: '**/$(Name).yaml'
targetFolder: '$(Build.ArtifactStagingDirectory)/$(Name)'
- displayName: Copy generated metadata
+ displayName: Copy generated OpenAPI yaml file to ArtifactStagingDirectory
+
- pwsh: |
./scripts/run-openapi-validation.ps1 -repoDirectory (Get-Location).Path -version "${{ parameters.endpoint }}" -platformName "$(Name)"
- displayName: ensure that OpenAPI docs can be parsed
+ displayName: Validate that OpenAPI docs can be parsed
workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
-
- job: publish_openapi
dependsOn: convert_openapi
- displayName: Publish
+ displayName: Publish OpenAPI files
## If there's new settings added please add them here too
templateContext:
inputs:
@@ -123,32 +132,31 @@ jobs:
displayName: checkout generator
fetchDepth: 1
persistCredentials: true
- # Copy files from the maxtrix artifacts to a single folder
+
+ # Note that msgraph-metadata repo has detached HEAD
+ - template: /.azure-pipelines/generation-templates/checkout-metadata.yml@self
+
+ - template: /.azure-pipelines/generation-templates/set-user-config.yml@self
+
+ # Copy OpenAPI files from the matrix artifacts to the ArtifactStagingDirectory
+ # This is used for library generation later
- task: CopyFiles@2
inputs:
sourceFolder: '$(Build.SourcesDirectory)/artifacts'
contents: '**/*.yaml'
targetFolder: '$(Build.ArtifactStagingDirectory)'
- displayName: Copy artifact metadata
- # Copy files from the target path where artifacts should be downloaded
+ displayName: Copy OpenAPI input artifacts to artifact staging directory
+
+ # Copy OpenAPI files from ArtifactStagingDirectory to local msgraph-metadata repo
- task: CopyFiles@2
inputs:
sourceFolder: '$(Build.ArtifactStagingDirectory)'
contents: '**/*.yaml'
targetFolder: '$(Build.SourcesDirectory)/msgraph-metadata/openapi/${{ parameters.endpoint }}'
- displayName: Copy downloaded metadata
+ displayName: Copy OpenAPI files to local msgraph-metadata repo
- # publish metadata as an artifact
- - task: CopyFiles@2
- inputs:
- sourceFolder: ${{ parameters.outputPath }}
- contents: '**/*.yaml'
- targetFolder: '$(Build.ArtifactStagingDirectory)'
- displayName: Copy downloaded metadata
- - template: /.azure-pipelines/generation-templates/checkout-metadata.yml@self
- - template: /.azure-pipelines/generation-templates/set-user-config.yml@self
+ # Push changes to msgraph-metadata repo
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
-
displayName: push clean ${{ parameters.endpoint }} OpenAPI description to msgraph-metadata repo
env:
EndpointVersion: ${{ parameters.endpoint }}
diff --git a/scripts/git-push-cleanmetadata.ps1 b/scripts/git-push-cleanmetadata.ps1
index cd33e51b1..92b7454f5 100644
--- a/scripts/git-push-cleanmetadata.ps1
+++ b/scripts/git-push-cleanmetadata.ps1
@@ -1,31 +1,61 @@
+# git-push-cleanmetadata.ps1
+# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the
+# project root for license information.
+
+# This script stashes any changes, checks out the latest master branch, applies the stashed changes, commits, and
+# pushes the changes back to the remote repository.
+
if ($env:PublishChanges -eq $False)
{
- Write-Host "Not publishing changes per the run parameter!" -ForegroundColor Green
+ Write-Host "Not publishing changes per the run parameter!" -ForegroundColor Red
return;
}
-Write-Host "About to add clean $env:EndpointVersion metadata file....."
+Write-Host "`nGet status:" -ForegroundColor Green
+git status | Write-Host -ForegroundColor Yellow
+
+Write-Host "`nStash the update metadata files.....`nRunning: git stash" -ForegroundColor Green
+git stash | Write-Host -ForegroundColor Yellow
-git fetch origin master
+Write-Host "`nFetching latest master branch to ensure we are up to date..." -ForegroundColor Green
+git fetch origin master | Write-Host -ForegroundColor Yellow
# checkout master to move from detached HEAD mode
-git switch master
+git switch master | Write-Host -ForegroundColor Yellow
+
+Write-Host "`nGet status:" -ForegroundColor Green
+git status | Write-Host -ForegroundColor Yellow
+
+Write-Host "`nApply stashed metadata files...`nRunning: git stash pop" -ForegroundColor Green
+git stash pop | Write-Host -ForegroundColor Yellow
+
+Write-Host "`nGet status:" -ForegroundColor Green
+git status | Write-Host -ForegroundColor Yellow
+
+Write-Host "`nStaging clean $env:EndpointVersion metadata files....." -ForegroundColor Green
+git add . | Write-Host -ForegroundColor Yellow
+
+Write-Host "`nGet status:" -ForegroundColor Green
+git status | Write-Host -ForegroundColor Yellow
+
+Write-Host "`nAttempting to commit clean $env:EndpointVersion metadata files....." -ForegroundColor Green
-git add . | Write-Host
if ($env:BUILD_REASON -eq 'Manual') # Skip CI if manually running this pipeline.
{
- git commit -m "Update clean metadata file with $env:BUILD_BUILDID [skip ci]" | Write-Host
+ git commit -m "Update clean metadata file with $env:BUILD_BUILDID [skip ci]" | Write-Host -ForegroundColor Yellow
}
else
{
- git commit -m "Update clean metadata file with $env:BUILD_BUILDID" | Write-Host
+ git commit -m "Update clean metadata file with $env:BUILD_BUILDID" | Write-Host -ForegroundColor Yellow
}
-Write-Host "Added and commited cleaned $env:EndpointVersion metadata." -ForegroundColor Green
+Write-Host "`nGet status:" -ForegroundColor Green
+git status | Write-Host -ForegroundColor Yellow
+Write-Host "`nRunning: git pull origin master --rebase..." -ForegroundColor Green
# sync branch before pushing
# this is especially important while running v1 and beta in parallel
# and one process goes out of sync because of the other's check-in
-git pull origin master --rebase
+git pull origin master --rebase | Write-Host -ForegroundColor Yellow
-git push --set-upstream origin master | Write-Host
-Write-Host "Pushed the results of the build $env:BUILD_BUILDID to the master branch." -ForegroundColor Green
\ No newline at end of file
+Write-Host "`nRunning: git push --set-upstream origin master ..." -ForegroundColor Green
+git push --set-upstream origin master | Write-Host -ForegroundColor Yellow
\ No newline at end of file
From 11a16eb5a3627a574abf29fc7ec9853802a4abd9 Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Sat, 18 Oct 2025 11:52:12 -0700
Subject: [PATCH 02/15] ci: add PR for OpenAPI files
---
.../generation-templates/capture-metadata.yml | 4 +--
.../generation-templates/capture-openapi.yml | 24 +++++++++++++
scripts/create-pull-request.ps1 | 3 +-
scripts/git-push-cleanmetadata.ps1 | 34 +++++++++++++++----
4 files changed, 55 insertions(+), 10 deletions(-)
diff --git a/.azure-pipelines/generation-templates/capture-metadata.yml b/.azure-pipelines/generation-templates/capture-metadata.yml
index 96637da28..2d5b55f8f 100644
--- a/.azure-pipelines/generation-templates/capture-metadata.yml
+++ b/.azure-pipelines/generation-templates/capture-metadata.yml
@@ -166,9 +166,9 @@ steps:
# Checkin clean metadata into metadata repo or make it an artifact.
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
-
- displayName: push clean ${{ parameters.endpoint }} metadata to msgraph-metadata repo
+ displayName: push clean ${{ parameters.endpoint }} CSDL metadata to msgraph-metadata repo
env:
+ CreatePR: False
EndpointVersion: ${{ parameters.endpoint }}
PublishChanges: $(publishChanges)
workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'
diff --git a/.azure-pipelines/generation-templates/capture-openapi.yml b/.azure-pipelines/generation-templates/capture-openapi.yml
index 1d546d54b..9a2d1da52 100644
--- a/.azure-pipelines/generation-templates/capture-openapi.yml
+++ b/.azure-pipelines/generation-templates/capture-openapi.yml
@@ -159,7 +159,31 @@ jobs:
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
displayName: push clean ${{ parameters.endpoint }} OpenAPI description to msgraph-metadata repo
env:
+ CreatePR: True
EndpointVersion: ${{ parameters.endpoint }}
PublishChanges: $(publishChanges)
workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'
enabled: true
+
+ # Create PR - note that this PR is not used for gating. It's just for discovery purposes. Library generation PRs will still
+ # be created based on the OpenAPI files.
+
+ - task: AzureKeyVault@2
+ displayName: "Azure Key Vault: Get Secrets"
+ inputs:
+ azureSubscription: "Federated AKV Managed Identity Connection"
+ KeyVaultName: akv-prod-eastus
+ SecretsFilter: "microsoft-graph-devx-bot-appid,microsoft-graph-devx-bot-privatekey"
+
+ - pwsh: '$(scriptsDirectory)/create-pull-request.ps1'
+ displayName: 'Create Pull Request for the generated OpenAPI files for msgraph-metadata'
+ env:
+ BaseBranch: master
+ GeneratePullRequest: true
+ GhAppId: $(microsoft-graph-devx-bot-appid)
+ GhAppKey: $(microsoft-graph-devx-bot-privatekey)
+ OverrideSkipCI: false
+ RepoName: 'microsoftgraph/msgraph-metadata'
+ ScriptsDirectory: $(scriptsDirectory)
+ Version: ''
+ workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'
\ No newline at end of file
diff --git a/scripts/create-pull-request.ps1 b/scripts/create-pull-request.ps1
index 6b4571f30..60fdafb80 100644
--- a/scripts/create-pull-request.ps1
+++ b/scripts/create-pull-request.ps1
@@ -9,6 +9,8 @@ if (($env:GeneratePullRequest -eq $False)) { # Skip CI if manually running this
return;
}
+$version = $env:Version
+
# Special case for beta typings as it uses a non-conforming preview versioning.
if ($env:RepoName.Contains("msgraph-beta-typescript-typings"))
{
@@ -18,7 +20,6 @@ else {
$title = "Generated $version models and request builders"
}
-$version = $env:Version
$body = ":bangbang:**_Important_**:bangbang:
Check for unexpected deletions or changes in this PR and ensure relevant CI checks are passing.
**Note:** This pull request was automatically created by Azure pipelines."
$baseBranchParameter = ""
diff --git a/scripts/git-push-cleanmetadata.ps1 b/scripts/git-push-cleanmetadata.ps1
index 92b7454f5..f443eb7c0 100644
--- a/scripts/git-push-cleanmetadata.ps1
+++ b/scripts/git-push-cleanmetadata.ps1
@@ -2,6 +2,10 @@
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the
# project root for license information.
+# Referenced by:
+# capture-metadata.yml
+# capture-openapi.yml
+
# This script stashes any changes, checks out the latest master branch, applies the stashed changes, commits, and
# pushes the changes back to the remote repository.
@@ -31,6 +35,12 @@ git stash pop | Write-Host -ForegroundColor Yellow
Write-Host "`nGet status:" -ForegroundColor Green
git status | Write-Host -ForegroundColor Yellow
+if ($env:CreatePR -eq $True)
+{
+ Write-Host "`nCreate branch: $env:BUILD_BUILDID/updateOpenAPI" -ForegroundColor Green
+ git checkout -B $env:BUILD_BUILDID/updateOpenAPI | Write-Host -ForegroundColor Yellow
+}
+
Write-Host "`nStaging clean $env:EndpointVersion metadata files....." -ForegroundColor Green
git add . | Write-Host -ForegroundColor Yellow
@@ -51,11 +61,21 @@ else
Write-Host "`nGet status:" -ForegroundColor Green
git status | Write-Host -ForegroundColor Yellow
-Write-Host "`nRunning: git pull origin master --rebase..." -ForegroundColor Green
-# sync branch before pushing
-# this is especially important while running v1 and beta in parallel
-# and one process goes out of sync because of the other's check-in
-git pull origin master --rebase | Write-Host -ForegroundColor Yellow
+if ($env:CreatePR -eq $True)
+{
+ Write-Host "`nPushing branch for PR creation" -ForegroundColor Green
+
+ Write-Host "`ngit push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI:" -ForegroundColor Green
+ git push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI | Write-Host -ForegroundColor Yellow
+}
+else # original behavior: push to master
+{
+ Write-Host "`nRunning: git pull origin master --rebase..." -ForegroundColor Green
+ # sync branch before pushing
+ # this is especially important while running v1 and beta in parallel
+ # and one process goes out of sync because of the other's check-in
+ git pull origin master --rebase | Write-Host -ForegroundColor Yellow
-Write-Host "`nRunning: git push --set-upstream origin master ..." -ForegroundColor Green
-git push --set-upstream origin master | Write-Host -ForegroundColor Yellow
\ No newline at end of file
+ Write-Host "`nRunning: git push --set-upstream origin master ..." -ForegroundColor Green
+ git push --set-upstream origin master | Write-Host -ForegroundColor Yellow
+}
\ No newline at end of file
From 1766791eab0ca5c1bc88c1eefd1289a698af88ee Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Sat, 18 Oct 2025 11:57:07 -0700
Subject: [PATCH 03/15] docs: clarify comments
---
.../generation-templates/capture-openapi.yml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/.azure-pipelines/generation-templates/capture-openapi.yml b/.azure-pipelines/generation-templates/capture-openapi.yml
index 9a2d1da52..950099000 100644
--- a/.azure-pipelines/generation-templates/capture-openapi.yml
+++ b/.azure-pipelines/generation-templates/capture-openapi.yml
@@ -155,18 +155,18 @@ jobs:
targetFolder: '$(Build.SourcesDirectory)/msgraph-metadata/openapi/${{ parameters.endpoint }}'
displayName: Copy OpenAPI files to local msgraph-metadata repo
- # Push changes to msgraph-metadata repo
+ # Push changes to msgraph-metadata repo and create PR
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
- displayName: push clean ${{ parameters.endpoint }} OpenAPI description to msgraph-metadata repo
+ displayName: PR for ${{ parameters.endpoint }} OpenAPI description in msgraph-metadata repo
env:
- CreatePR: True
+ CreatePR: True
EndpointVersion: ${{ parameters.endpoint }}
PublishChanges: $(publishChanges)
workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'
enabled: true
- # Create PR - note that this PR is not used for gating. It's just for discovery purposes. Library generation PRs will still
- # be created based on the OpenAPI files.
+ # Create PR - note that this PR is not used for gating. It's just for discovery purposes.
+ # Library generation PRs will still be created based on the OpenAPI files.
- task: AzureKeyVault@2
displayName: "Azure Key Vault: Get Secrets"
From 9b0f79168e630e7ec6a0a96420d929db2588cc1a Mon Sep 17 00:00:00 2001
From: Michael Mainer <8527305+MIchaelMainer@users.noreply.github.com>
Date: Sat, 18 Oct 2025 12:05:19 -0700
Subject: [PATCH 04/15] Update scripts/git-push-cleanmetadata.ps1
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---
scripts/git-push-cleanmetadata.ps1 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/git-push-cleanmetadata.ps1 b/scripts/git-push-cleanmetadata.ps1
index f443eb7c0..4c06a64fd 100644
--- a/scripts/git-push-cleanmetadata.ps1
+++ b/scripts/git-push-cleanmetadata.ps1
@@ -11,7 +11,7 @@
if ($env:PublishChanges -eq $False)
{
- Write-Host "Not publishing changes per the run parameter!" -ForegroundColor Red
+ Write-Host "Not publishing changes per the run parameter!" -ForegroundColor Yellow
return;
}
From fb841ba19cc3e189e72984363a81aa251472e639 Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Sat, 18 Oct 2025 12:12:37 -0700
Subject: [PATCH 05/15] ci: clarify use of version when creating PR
---
.../generation-templates/capture-openapi.yml | 1 +
scripts/create-pull-request.ps1 | 16 +++++++++-------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/.azure-pipelines/generation-templates/capture-openapi.yml b/.azure-pipelines/generation-templates/capture-openapi.yml
index 950099000..db80b7782 100644
--- a/.azure-pipelines/generation-templates/capture-openapi.yml
+++ b/.azure-pipelines/generation-templates/capture-openapi.yml
@@ -185,5 +185,6 @@ jobs:
OverrideSkipCI: false
RepoName: 'microsoftgraph/msgraph-metadata'
ScriptsDirectory: $(scriptsDirectory)
+ # Version is intentionally left empty for OpenAPI PRs as versioning is not applicable in this context.
Version: ''
workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'
\ No newline at end of file
diff --git a/scripts/create-pull-request.ps1 b/scripts/create-pull-request.ps1
index 60fdafb80..e283a4222 100644
--- a/scripts/create-pull-request.ps1
+++ b/scripts/create-pull-request.ps1
@@ -11,15 +11,17 @@ if (($env:GeneratePullRequest -eq $False)) { # Skip CI if manually running this
$version = $env:Version
-# Special case for beta typings as it uses a non-conforming preview versioning.
-if ($env:RepoName.Contains("msgraph-beta-typescript-typings"))
+if ($version -ne '')
{
- $title = "feat: generated $version models and request builders"
+ # Special case for beta typings as it uses a non-conforming preview versioning. Helps with triggering Release Please.
+ if ($env:RepoName.Contains("msgraph-beta-typescript-typings"))
+ {
+ $title = "feat: generated $version models and request builders"
+ }
+ else {
+ $title = "Generated $version models and request builders"
+ }
}
-else {
- $title = "Generated $version models and request builders"
-}
-
$body = ":bangbang:**_Important_**:bangbang:
Check for unexpected deletions or changes in this PR and ensure relevant CI checks are passing.
**Note:** This pull request was automatically created by Azure pipelines."
$baseBranchParameter = ""
From 4c2f858fe1b44f9305eefcb4e6f7d5ac4b1ceac4 Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Mon, 20 Oct 2025 10:08:31 -0700
Subject: [PATCH 06/15] ci: remove display name from template use
---
.azure-pipelines/generation-templates/capture-openapi.yml | 3 +--
.azure-pipelines/generation-templates/use-dotnet-sdk.yml | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/.azure-pipelines/generation-templates/capture-openapi.yml b/.azure-pipelines/generation-templates/capture-openapi.yml
index db80b7782..362ebbbbf 100644
--- a/.azure-pipelines/generation-templates/capture-openapi.yml
+++ b/.azure-pipelines/generation-templates/capture-openapi.yml
@@ -66,12 +66,11 @@ jobs:
- template: /.azure-pipelines/generation-templates/use-dotnet-sdk.yml@self
parameters:
version: '8.x'
- displayName: use dotnet sdk 8.x
+
# required for the hidi installation validation
- template: /.azure-pipelines/generation-templates/use-dotnet-sdk.yml@self
parameters:
version: '9.x'
- displayName: use dotnet sdk 9.x
- pwsh: dotnet tool install --global Microsoft.OpenApi.Hidi --version 1.6.24
displayName: install hidi
diff --git a/.azure-pipelines/generation-templates/use-dotnet-sdk.yml b/.azure-pipelines/generation-templates/use-dotnet-sdk.yml
index 24246b344..700958ae7 100644
--- a/.azure-pipelines/generation-templates/use-dotnet-sdk.yml
+++ b/.azure-pipelines/generation-templates/use-dotnet-sdk.yml
@@ -5,7 +5,7 @@ parameters:
steps:
- task: UseDotNet@2
- displayName: 'Use .NET SDK'
+ displayName: 'Use .NET SDK ${{ parameters.version }}'
inputs:
packageType: sdk
version: ${{ parameters.version }}
From 24a0a8ec9dcdf38e637cf1cdf839e4a700bf9f5d Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Mon, 20 Oct 2025 12:34:00 -0700
Subject: [PATCH 07/15] ci update logging
---
.../generation-templates/capture-openapi.yml | 15 +++--
scripts/create-pull-request.ps1 | 8 +--
scripts/generate-open-api.ps1 | 19 ++++--
scripts/git-push-cleanmetadata.ps1 | 64 +++++++++----------
4 files changed, 57 insertions(+), 49 deletions(-)
diff --git a/.azure-pipelines/generation-templates/capture-openapi.yml b/.azure-pipelines/generation-templates/capture-openapi.yml
index 362ebbbbf..50f96ee6c 100644
--- a/.azure-pipelines/generation-templates/capture-openapi.yml
+++ b/.azure-pipelines/generation-templates/capture-openapi.yml
@@ -76,17 +76,17 @@ jobs:
displayName: install hidi
- pwsh: |
- git fetch origin master | Write-Host -ForegroundColor Yellow
- git switch master | Write-Host -ForegroundColor Yellow
+ git fetch origin master
+ git switch master
displayName: ensure the generation happens from master latest
workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
- pwsh: |
- Write-Host "`nGet status before generation:" -ForegroundColor Green
- git status | Write-Host -ForegroundColor Yellow
+ Write-Host "`ngit status before generation:"
+ git status
$(scriptsDirectory)/generate-open-api.ps1 -endpointVersion ${{ parameters.endpoint }} -settings "$(conversionSettingsDirectory)/$(File)" -platformName "$(Name)"
- Write-Host "`nGet status after generation:" -ForegroundColor Green
- git status | Write-Host -ForegroundColor Yellow
+ Write-Host "`ngit status after generation:"
+ git status
displayName: 'generate ${{ parameters.endpoint }} open API description'
workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
@@ -153,6 +153,8 @@ jobs:
contents: '**/*.yaml'
targetFolder: '$(Build.SourcesDirectory)/msgraph-metadata/openapi/${{ parameters.endpoint }}'
displayName: Copy OpenAPI files to local msgraph-metadata repo
+ overwrite: true
+
# Push changes to msgraph-metadata repo and create PR
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
@@ -163,6 +165,7 @@ jobs:
PublishChanges: $(publishChanges)
workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'
enabled: true
+
# Create PR - note that this PR is not used for gating. It's just for discovery purposes.
# Library generation PRs will still be created based on the OpenAPI files.
diff --git a/scripts/create-pull-request.ps1 b/scripts/create-pull-request.ps1
index e283a4222..aa7970575 100644
--- a/scripts/create-pull-request.ps1
+++ b/scripts/create-pull-request.ps1
@@ -1,11 +1,11 @@
if (($env:OverrideSkipCI -eq $False) -and ($env:BUILD_REASON -eq 'Manual')) # Skip CI if manually running this pipeline.
{
- Write-Host "Skipping pull request creation due Skip CI." -ForegroundColor Green
+ Write-Host "Skipping pull request creation due Skip CI."
return;
}
if (($env:GeneratePullRequest -eq $False)) { # Skip CI if manually running this pipeline.
- Write-Host "Skipping pull request creation due this repository being disabled" -ForegroundColor Green
+ Write-Host "Skipping pull request creation due this repository being disabled"
return;
}
@@ -33,10 +33,10 @@ if (![string]::IsNullOrEmpty($env:BaseBranch))
# The installed application is required to have the following permissions: read/write on pull requests/
$tokenGenerationScript = "$env:ScriptsDirectory\Generate-Github-Token.ps1"
$env:GITHUB_TOKEN = & $tokenGenerationScript -AppClientId $env:GhAppId -AppPrivateKeyContents $env:GhAppKey -Repository $env:RepoName
-Write-Host "Fetched Github Token for PR generation and set as environment variable." -ForegroundColor Green
+Write-Host "Fetched Github Token for PR generation and set as environment variable."
# No need to specify reviewers as code owners should be added automatically.
Invoke-Expression "gh auth login" # login to GitHub
Invoke-Expression "gh pr create -t ""$title"" -b ""$body"" $baseBranchParameter | Write-Host"
-Write-Host "Pull Request Created successfully." -ForegroundColor Green
\ No newline at end of file
+Write-Host "Pull Request Created successfully."
\ No newline at end of file
diff --git a/scripts/generate-open-api.ps1 b/scripts/generate-open-api.ps1
index a3634f115..1788e484b 100644
--- a/scripts/generate-open-api.ps1
+++ b/scripts/generate-open-api.ps1
@@ -21,6 +21,8 @@ param(
[parameter(Mandatory = $true)][String]$platformName
)
+Write-Host "Starting $endpointVersion OpenAPI generation for $platformName using generate-open-api.ps1"
+
$outputFile = Join-Path "./" "openapi" $endpointVersion "$platformName.yaml"
$oldOutputFile = "$outputFile.old"
$cleanVersion = $endpointVersion.Replace(".", "")
@@ -34,16 +36,16 @@ if($platformName -eq "openapi")
$fileName = "$baseFileName$endpointVersion.xml";
$inputFile = Join-Path "./" "clean_$($cleanVersion)_metadata" "$fileName"
-Write-Host "Settings: $settings"
-Write-Verbose "Generating OpenAPI description from $inputFile"
-Write-Verbose "Output file: $outputFile"
+Write-Host "`nSettings: $settings"
+Write-Host "Generating OpenAPI description from $inputFile"
+Write-Host "Output file: $outputFile"
if(Test-Path $outputFile)
{
- Write-Verbose "Removing existing output file"
+ Write-Host "`nRemoving existing output file"
if(Test-Path $oldOutputFile)
{
- Write-Verbose "Removing existing old output file"
+ Write-Host "Removing existing old output file: $oldOutputFile"
Remove-Item $oldOutputFile -Force
}
$oldFileName = Split-Path $outputFile -leaf
@@ -51,6 +53,7 @@ if(Test-Path $outputFile)
Rename-Item $outputFile $oldFileName
}
+Write-Host "`nGenerating OpenAPI description using hidi..."
$command = "hidi transform --csdl ""$inputFile"" --output ""$outputFile"" --settings-path ""$settings"" --version ""3.0"" --metadata-version ""$endpointVersion"" --log-level Information --format yaml"
Write-Host $command
@@ -62,16 +65,18 @@ try {
Set-Content $outputFile $updatedContent -NoNewline
if(Test-Path $oldOutputFile)
{
- Write-Verbose "Removing existing old output file"
+ Write-Host "`nRemoving existing old output file: $oldOutputFile"
Remove-Item $oldOutputFile -Force
}
+ Write-Host "Completed generating OpenAPI description using hidi"
} catch {
if(Test-Path $oldOutputFile)
{
- Write-Warning "Restoring old output file"
+ Write-Host "`nRestoring old output file: $oldOutputFile"
$originalFileName = Split-Path $outputFile -leaf
Rename-Item $oldOutputFile $originalFileName
}
Write-Error "Error generating OpenAPI description: $_"
throw $_
}
+
diff --git a/scripts/git-push-cleanmetadata.ps1 b/scripts/git-push-cleanmetadata.ps1
index 4c06a64fd..8a20ff229 100644
--- a/scripts/git-push-cleanmetadata.ps1
+++ b/scripts/git-push-cleanmetadata.ps1
@@ -11,71 +11,71 @@
if ($env:PublishChanges -eq $False)
{
- Write-Host "Not publishing changes per the run parameter!" -ForegroundColor Yellow
+ Write-Host "Not publishing changes per the run parameter!"
return;
}
-Write-Host "`nGet status:" -ForegroundColor Green
-git status | Write-Host -ForegroundColor Yellow
+Write-Host "`ngit status:"
+git status | Write-Host
-Write-Host "`nStash the update metadata files.....`nRunning: git stash" -ForegroundColor Green
-git stash | Write-Host -ForegroundColor Yellow
+Write-Host "`nStash the update metadata files.....`nRunning: git stash"
+git stash | Write-Host
-Write-Host "`nFetching latest master branch to ensure we are up to date..." -ForegroundColor Green
-git fetch origin master | Write-Host -ForegroundColor Yellow
+Write-Host "`nFetching latest master branch to ensure we are up to date..."
+git fetch origin master | Write-Host
# checkout master to move from detached HEAD mode
-git switch master | Write-Host -ForegroundColor Yellow
+git switch master | Write-Host
-Write-Host "`nGet status:" -ForegroundColor Green
-git status | Write-Host -ForegroundColor Yellow
+Write-Host "`ngit status:"
+git status | Write-Host
-Write-Host "`nApply stashed metadata files...`nRunning: git stash pop" -ForegroundColor Green
-git stash pop | Write-Host -ForegroundColor Yellow
+Write-Host "`nApply stashed metadata files...`nRunning: git stash pop"
+git stash pop | Write-Host
-Write-Host "`nGet status:" -ForegroundColor Green
-git status | Write-Host -ForegroundColor Yellow
+Write-Host "`ngit status:"
+git status | Write-Host
if ($env:CreatePR -eq $True)
{
- Write-Host "`nCreate branch: $env:BUILD_BUILDID/updateOpenAPI" -ForegroundColor Green
- git checkout -B $env:BUILD_BUILDID/updateOpenAPI | Write-Host -ForegroundColor Yellow
+ Write-Host "`nCreate branch: $env:BUILD_BUILDID/updateOpenAPI"
+ git checkout -B $env:BUILD_BUILDID/updateOpenAPI | Write-Host
}
-Write-Host "`nStaging clean $env:EndpointVersion metadata files....." -ForegroundColor Green
-git add . | Write-Host -ForegroundColor Yellow
+Write-Host "`nStaging clean $env:EndpointVersion metadata files.....`nRunning: git add ."
+git add . | Write-Host
-Write-Host "`nGet status:" -ForegroundColor Green
-git status | Write-Host -ForegroundColor Yellow
+Write-Host "`ngit status:"
+git status | Write-Host
-Write-Host "`nAttempting to commit clean $env:EndpointVersion metadata files....." -ForegroundColor Green
+Write-Host "`nAttempting to commit clean $env:EndpointVersion metadata files....."
if ($env:BUILD_REASON -eq 'Manual') # Skip CI if manually running this pipeline.
{
- git commit -m "Update clean metadata file with $env:BUILD_BUILDID [skip ci]" | Write-Host -ForegroundColor Yellow
+ git commit -m "Update clean metadata file with $env:BUILD_BUILDID [skip ci]" | Write-Host
}
else
{
- git commit -m "Update clean metadata file with $env:BUILD_BUILDID" | Write-Host -ForegroundColor Yellow
+ git commit -m "Update clean metadata file with $env:BUILD_BUILDID" | Write-Host
}
-Write-Host "`nGet status:" -ForegroundColor Green
-git status | Write-Host -ForegroundColor Yellow
+Write-Host "`ngit status:"
+git status | Write-Host
if ($env:CreatePR -eq $True)
{
- Write-Host "`nPushing branch for PR creation" -ForegroundColor Green
+ Write-Host "`nPushing branch for PR creation"
- Write-Host "`ngit push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI:" -ForegroundColor Green
- git push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI | Write-Host -ForegroundColor Yellow
+ Write-Host "`ngit push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI:"
+ git push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI | Write-Host
}
else # original behavior: push to master
{
- Write-Host "`nRunning: git pull origin master --rebase..." -ForegroundColor Green
+ Write-Host "`nRunning: git pull origin master --rebase..."
# sync branch before pushing
# this is especially important while running v1 and beta in parallel
# and one process goes out of sync because of the other's check-in
- git pull origin master --rebase | Write-Host -ForegroundColor Yellow
+ git pull origin master --rebase | Write-Host
- Write-Host "`nRunning: git push --set-upstream origin master ..." -ForegroundColor Green
- git push --set-upstream origin master | Write-Host -ForegroundColor Yellow
+ Write-Host "`nRunning: git push --set-upstream origin master ..."
+ git push --set-upstream origin master | Write-Host
}
\ No newline at end of file
From a941ba6531840806e8299eba2c95e037da7a0609 Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Mon, 20 Oct 2025 12:37:31 -0700
Subject: [PATCH 08/15] ci: correct the copyfile overwrite parameter
---
.azure-pipelines/generation-templates/capture-openapi.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.azure-pipelines/generation-templates/capture-openapi.yml b/.azure-pipelines/generation-templates/capture-openapi.yml
index 50f96ee6c..5fd431784 100644
--- a/.azure-pipelines/generation-templates/capture-openapi.yml
+++ b/.azure-pipelines/generation-templates/capture-openapi.yml
@@ -152,9 +152,8 @@ jobs:
sourceFolder: '$(Build.ArtifactStagingDirectory)'
contents: '**/*.yaml'
targetFolder: '$(Build.SourcesDirectory)/msgraph-metadata/openapi/${{ parameters.endpoint }}'
+ overwrite: true
displayName: Copy OpenAPI files to local msgraph-metadata repo
- overwrite: true
-
# Push changes to msgraph-metadata repo and create PR
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
From 4ddd9be286fe8b59fa677d41148280cb9bc5b379 Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Tue, 21 Oct 2025 12:56:16 -0700
Subject: [PATCH 09/15] ci: add approval step for OpenAPI before running Kiota
generation
---
.azure-pipelines/generation-pipeline.yml | 40 ++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/.azure-pipelines/generation-pipeline.yml b/.azure-pipelines/generation-pipeline.yml
index c377407b3..eecbf9117 100644
--- a/.azure-pipelines/generation-pipeline.yml
+++ b/.azure-pipelines/generation-pipeline.yml
@@ -298,10 +298,34 @@ extends:
outputPath: $(cleanOpenAPIFileBetaOutputPath)
cleanMetadataFolder: $(cleanOpenAPIFolderBeta)
+ # Approval stage for OpenAPI generation. All subsequent stages depending on OpenAPI generation
+ # will be blocked until approval is granted. Any new stages depending on OpenAPI generation
+ # should also depend on this approval stage.
+ - stage: open_api_approval
+ dependsOn:
+ - stage_v1_openapi
+ - stage_beta_openapi
+ condition: |
+ or
+ (
+ eq(dependencies.stage_v1_openapi.result, 'Succeeded'),
+ eq(dependencies.stage_beta_openapi.result, 'Succeeded')
+ )
+ jobs:
+ - deployment: OpenApiApproval
+ displayName: 'OpenAPI Generation Review'
+ environment: 'openapi-generation-review'
+ strategy:
+ runOnce:
+ deploy:
+ steps:
+ - script: echo "OpenAPI generation approved."
+
- stage: stage_csharp_v1_kiota
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
+ - open_api_approval
condition: |
and
(
@@ -343,6 +367,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
+ - open_api_approval
condition: |
and
(
@@ -384,6 +409,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
+ - open_api_approval
condition: |
and
(
@@ -423,6 +449,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
+ - open_api_approval
condition: |
and
(
@@ -462,6 +489,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
+ - open_api_approval
condition: |
and
(
@@ -503,6 +531,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
+ - open_api_approval
condition: |
and
(
@@ -544,6 +573,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
+ - open_api_approval
condition: |
and
(
@@ -585,6 +615,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
+ - open_api_approval
condition: |
and
(
@@ -626,6 +657,7 @@ extends:
dependsOn:
- stage_build_and_publish_typewriter
- stage_v1_metadata
+ - open_api_approval
condition: |
and
(
@@ -663,6 +695,7 @@ extends:
dependsOn:
- stage_build_and_publish_typewriter
- stage_beta_metadata
+ - open_api_approval
condition: |
and
(
@@ -700,6 +733,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
+ - open_api_approval
condition: |
and
(
@@ -742,6 +776,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
+ - open_api_approval
condition: |
and
(
@@ -784,6 +819,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
+ - open_api_approval
condition: |
and
(
@@ -824,6 +860,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
+ - open_api_approval
condition: |
and
(
@@ -864,6 +901,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
+ - open_api_approval
condition: |
and
(
@@ -907,6 +945,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
+ - open_api_approval
condition: |
and
(
@@ -950,6 +989,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
+ - open_api_approval
condition: |
and
(
From fb938e508ffaae063a891261347f96417fac8f4d Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Tue, 21 Oct 2025 14:30:56 -0700
Subject: [PATCH 10/15] ci: update env var name
---
.azure-pipelines/generation-templates/capture-metadata.yml | 2 +-
.azure-pipelines/generation-templates/capture-openapi.yml | 2 +-
scripts/git-push-cleanmetadata.ps1 | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/.azure-pipelines/generation-templates/capture-metadata.yml b/.azure-pipelines/generation-templates/capture-metadata.yml
index 2d5b55f8f..4a6fb2377 100644
--- a/.azure-pipelines/generation-templates/capture-metadata.yml
+++ b/.azure-pipelines/generation-templates/capture-metadata.yml
@@ -168,7 +168,7 @@ steps:
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
displayName: push clean ${{ parameters.endpoint }} CSDL metadata to msgraph-metadata repo
env:
- CreatePR: False
+ CreateOpenAPIPR: False
EndpointVersion: ${{ parameters.endpoint }}
PublishChanges: $(publishChanges)
workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'
diff --git a/.azure-pipelines/generation-templates/capture-openapi.yml b/.azure-pipelines/generation-templates/capture-openapi.yml
index 5fd431784..a153b3bf1 100644
--- a/.azure-pipelines/generation-templates/capture-openapi.yml
+++ b/.azure-pipelines/generation-templates/capture-openapi.yml
@@ -159,7 +159,7 @@ jobs:
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
displayName: PR for ${{ parameters.endpoint }} OpenAPI description in msgraph-metadata repo
env:
- CreatePR: True
+ CreateOpenAPIPR: True
EndpointVersion: ${{ parameters.endpoint }}
PublishChanges: $(publishChanges)
workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'
diff --git a/scripts/git-push-cleanmetadata.ps1 b/scripts/git-push-cleanmetadata.ps1
index 8a20ff229..2098337ff 100644
--- a/scripts/git-push-cleanmetadata.ps1
+++ b/scripts/git-push-cleanmetadata.ps1
@@ -35,7 +35,7 @@ git stash pop | Write-Host
Write-Host "`ngit status:"
git status | Write-Host
-if ($env:CreatePR -eq $True)
+if ($env:CreateOpenAPIPR -eq $True)
{
Write-Host "`nCreate branch: $env:BUILD_BUILDID/updateOpenAPI"
git checkout -B $env:BUILD_BUILDID/updateOpenAPI | Write-Host
@@ -61,7 +61,7 @@ else
Write-Host "`ngit status:"
git status | Write-Host
-if ($env:CreatePR -eq $True)
+if ($env:CreateOpenAPIPR -eq $True)
{
Write-Host "`nPushing branch for PR creation"
From 46662544dadd1323faf539d7f0d41b15bb6646c3 Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Tue, 21 Oct 2025 15:07:33 -0700
Subject: [PATCH 11/15] ci: typings gen does not use open_api
---
.azure-pipelines/generation-pipeline.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.azure-pipelines/generation-pipeline.yml b/.azure-pipelines/generation-pipeline.yml
index eecbf9117..9d7af854e 100644
--- a/.azure-pipelines/generation-pipeline.yml
+++ b/.azure-pipelines/generation-pipeline.yml
@@ -657,7 +657,6 @@ extends:
dependsOn:
- stage_build_and_publish_typewriter
- stage_v1_metadata
- - open_api_approval
condition: |
and
(
@@ -695,7 +694,6 @@ extends:
dependsOn:
- stage_build_and_publish_typewriter
- stage_beta_metadata
- - open_api_approval
condition: |
and
(
From efe36c05ef830dc17f47f2dc96f58242d7fababc Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Wed, 22 Oct 2025 11:56:26 -0700
Subject: [PATCH 12/15] ci: name branch using endpointversion, add clarity for
host output
---
scripts/git-push-cleanmetadata.ps1 | 42 ++++++++++++++++--------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/scripts/git-push-cleanmetadata.ps1 b/scripts/git-push-cleanmetadata.ps1
index 2098337ff..fbaed0ced 100644
--- a/scripts/git-push-cleanmetadata.ps1
+++ b/scripts/git-push-cleanmetadata.ps1
@@ -15,67 +15,71 @@ if ($env:PublishChanges -eq $False)
return;
}
-Write-Host "`ngit status:"
+Write-Host "`n1. git status:"
git status | Write-Host
-Write-Host "`nStash the update metadata files.....`nRunning: git stash"
+Write-Host "`n2. Stash the update metadata files.....`n3. Running: git stash"
git stash | Write-Host
-Write-Host "`nFetching latest master branch to ensure we are up to date..."
+Write-Host "`n4. Fetching latest master branch to ensure we are up to date..."
git fetch origin master | Write-Host
# checkout master to move from detached HEAD mode
git switch master | Write-Host
-Write-Host "`ngit status:"
+
+
+Write-Host "`n5. git status:"
git status | Write-Host
-Write-Host "`nApply stashed metadata files...`nRunning: git stash pop"
+Write-Host "`n6. Apply stashed metadata files...`n7. Running: git stash pop"
git stash pop | Write-Host
-Write-Host "`ngit status:"
+Write-Host "`n8. git status:"
git status | Write-Host
+$branch = "$env:EndpointVersion/$env:BUILD_BUILDID/updateOpenAPI"
+
if ($env:CreateOpenAPIPR -eq $True)
{
- Write-Host "`nCreate branch: $env:BUILD_BUILDID/updateOpenAPI"
- git checkout -B $env:BUILD_BUILDID/updateOpenAPI | Write-Host
+ Write-Host "`n9. Create branch: $branch"
+ git checkout -B $branch | Write-Host
}
-Write-Host "`nStaging clean $env:EndpointVersion metadata files.....`nRunning: git add ."
+Write-Host "`n10. Staging clean $env:EndpointVersion metadata files.....`n11. Running: git add ."
git add . | Write-Host
-Write-Host "`ngit status:"
+Write-Host "`n12. git status:"
git status | Write-Host
-Write-Host "`nAttempting to commit clean $env:EndpointVersion metadata files....."
+Write-Host "`n13. Attempting to commit clean $env:EndpointVersion metadata files....."
if ($env:BUILD_REASON -eq 'Manual') # Skip CI if manually running this pipeline.
{
- git commit -m "Update clean metadata file with $env:BUILD_BUILDID [skip ci]" | Write-Host
+ git commit -m "Update clean $env:EndpointVersion metadata file with $env:BUILD_BUILDID [skip ci]" | Write-Host
}
else
{
- git commit -m "Update clean metadata file with $env:BUILD_BUILDID" | Write-Host
+ git commit -m "Update clean $env:EndpointVersion metadata file with $env:BUILD_BUILDID" | Write-Host
}
-Write-Host "`ngit status:"
+Write-Host "`n14. git status:"
git status | Write-Host
if ($env:CreateOpenAPIPR -eq $True)
{
- Write-Host "`nPushing branch for PR creation"
+ Write-Host "`n15a. Pushing branch for PR creation"
- Write-Host "`ngit push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI:"
- git push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI | Write-Host
+ Write-Host "`n15b. Running: git push --set-upstream origin $branch"
+ git push --set-upstream origin $branch | Write-Host
}
else # original behavior: push to master
{
- Write-Host "`nRunning: git pull origin master --rebase..."
+ Write-Host "`n15c. Running: git pull origin master --rebase..."
# sync branch before pushing
# this is especially important while running v1 and beta in parallel
# and one process goes out of sync because of the other's check-in
git pull origin master --rebase | Write-Host
- Write-Host "`nRunning: git push --set-upstream origin master ..."
+ Write-Host "`n15d. Running: git push --set-upstream origin master ..."
git push --set-upstream origin master | Write-Host
}
\ No newline at end of file
From eee6fef82bdc68b8741edfb0acf7ec3a3a2cf659 Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Wed, 22 Oct 2025 15:41:54 -0700
Subject: [PATCH 13/15] ci: update for supporting builds
---
.../generation-templates/capture-openapi.yml | 4 ++--
scripts/create-pull-request.ps1 | 18 +++++++-----------
scripts/git-push-cleanmetadata.ps1 | 2 +-
3 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/.azure-pipelines/generation-templates/capture-openapi.yml b/.azure-pipelines/generation-templates/capture-openapi.yml
index a153b3bf1..499723f06 100644
--- a/.azure-pipelines/generation-templates/capture-openapi.yml
+++ b/.azure-pipelines/generation-templates/capture-openapi.yml
@@ -155,9 +155,9 @@ jobs:
overwrite: true
displayName: Copy OpenAPI files to local msgraph-metadata repo
- # Push changes to msgraph-metadata repo and create PR
+ # Push changes to msgraph-metadata repo
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
- displayName: PR for ${{ parameters.endpoint }} OpenAPI description in msgraph-metadata repo
+ displayName: Publish ${{ parameters.endpoint }} OpenAPI description to msgraph-metadata repo
env:
CreateOpenAPIPR: True
EndpointVersion: ${{ parameters.endpoint }}
diff --git a/scripts/create-pull-request.ps1 b/scripts/create-pull-request.ps1
index aa7970575..f1729a77c 100644
--- a/scripts/create-pull-request.ps1
+++ b/scripts/create-pull-request.ps1
@@ -9,19 +9,15 @@ if (($env:GeneratePullRequest -eq $False)) { # Skip CI if manually running this
return;
}
-$version = $env:Version
-
-if ($version -ne '')
+# Special case for beta typings as it uses a non-conforming preview versioning. Helps with triggering Release Please.
+if ($env:RepoName.Contains("msgraph-beta-typescript-typings"))
{
- # Special case for beta typings as it uses a non-conforming preview versioning. Helps with triggering Release Please.
- if ($env:RepoName.Contains("msgraph-beta-typescript-typings"))
- {
- $title = "feat: generated $version models and request builders"
- }
- else {
- $title = "Generated $version models and request builders"
- }
+ $title = "feat: generated $env:Version models and request builders"
+}
+else {
+ $title = "Generated $env:Version models and request builders"
}
+
$body = ":bangbang:**_Important_**:bangbang:
Check for unexpected deletions or changes in this PR and ensure relevant CI checks are passing.
**Note:** This pull request was automatically created by Azure pipelines."
$baseBranchParameter = ""
diff --git a/scripts/git-push-cleanmetadata.ps1 b/scripts/git-push-cleanmetadata.ps1
index fbaed0ced..a580d8a89 100644
--- a/scripts/git-push-cleanmetadata.ps1
+++ b/scripts/git-push-cleanmetadata.ps1
@@ -37,7 +37,7 @@ git stash pop | Write-Host
Write-Host "`n8. git status:"
git status | Write-Host
-$branch = "$env:EndpointVersion/$env:BUILD_BUILDID/updateOpenAPI"
+$branch = "publish-open-api-files/$env:BUILD_BUILDID/$env:EndpointVersion"
if ($env:CreateOpenAPIPR -eq $True)
{
From 1ee63da764d18499e4dada1a7fc9132f8d9b84f8 Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Wed, 22 Oct 2025 16:57:00 -0700
Subject: [PATCH 14/15] ci: add PR title for OpenAPI PRs
---
scripts/create-pull-request.ps1 | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/scripts/create-pull-request.ps1 b/scripts/create-pull-request.ps1
index f1729a77c..d8932c341 100644
--- a/scripts/create-pull-request.ps1
+++ b/scripts/create-pull-request.ps1
@@ -14,6 +14,10 @@ if ($env:RepoName.Contains("msgraph-beta-typescript-typings"))
{
$title = "feat: generated $env:Version models and request builders"
}
+elseif ($env:RepoName.Contains("msgraph-metadata")) # we are only generating OpenAPI PRs for the metadata repo
+{
+ $title = "Generated $env:Version OpenAPI descriptions"
+}
else {
$title = "Generated $env:Version models and request builders"
}
From 53d8d25e8b62f88fcb8f18b04fa09f393f61ca96 Mon Sep 17 00:00:00 2001
From: "Michael Mainer (from Dev Box)"
<8527305+MIchaelMainer@users.noreply.github.com>
Date: Thu, 23 Oct 2025 13:12:29 -0700
Subject: [PATCH 15/15] ci: add beta openapi approval step
---
.azure-pipelines/generation-pipeline.yml | 58 ++++++++++++++----------
1 file changed, 33 insertions(+), 25 deletions(-)
diff --git a/.azure-pipelines/generation-pipeline.yml b/.azure-pipelines/generation-pipeline.yml
index 9d7af854e..46e179ea7 100644
--- a/.azure-pipelines/generation-pipeline.yml
+++ b/.azure-pipelines/generation-pipeline.yml
@@ -298,22 +298,16 @@ extends:
outputPath: $(cleanOpenAPIFileBetaOutputPath)
cleanMetadataFolder: $(cleanOpenAPIFolderBeta)
- # Approval stage for OpenAPI generation. All subsequent stages depending on OpenAPI generation
+ # Approval stage for v1 OpenAPI generation. All subsequent stages depending on OpenAPI generation
# will be blocked until approval is granted. Any new stages depending on OpenAPI generation
# should also depend on this approval stage.
- - stage: open_api_approval
+ - stage: open_api_v1_approval
dependsOn:
- stage_v1_openapi
- - stage_beta_openapi
- condition: |
- or
- (
- eq(dependencies.stage_v1_openapi.result, 'Succeeded'),
- eq(dependencies.stage_beta_openapi.result, 'Succeeded')
- )
+ condition: eq(dependencies.stage_v1_openapi.result, 'Succeeded')
jobs:
- deployment: OpenApiApproval
- displayName: 'OpenAPI Generation Review'
+ displayName: 'OpenAPI v1.0 Generation Review'
environment: 'openapi-generation-review'
strategy:
runOnce:
@@ -321,11 +315,28 @@ extends:
steps:
- script: echo "OpenAPI generation approved."
+ # Approval stage for beta OpenAPI generation. All subsequent stages depending on OpenAPI generation
+ # will be blocked until approval is granted. Any new stages depending on OpenAPI generation
+ # should also depend on this approval stage.
+ - stage: open_api_beta_approval
+ dependsOn:
+ - stage_beta_openapi
+ condition: eq(dependencies.stage_beta_openapi.result, 'Succeeded')
+ jobs:
+ - deployment: OpenApiApproval
+ displayName: 'OpenAPI Beta Generation Review'
+ environment: 'openapi-generation-review'
+ strategy:
+ runOnce:
+ deploy:
+ steps:
+ - script: echo "OpenAPI generation approved."
+
- stage: stage_csharp_v1_kiota
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
- - open_api_approval
+ - open_api_v1_approval
condition: |
and
(
@@ -367,7 +378,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
- - open_api_approval
+ - open_api_beta_approval
condition: |
and
(
@@ -409,7 +420,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
- - open_api_approval
+ - open_api_v1_approval
condition: |
and
(
@@ -449,7 +460,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
- - open_api_approval
+ - open_api_beta_approval
condition: |
and
(
@@ -489,7 +500,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
- - open_api_approval
+ - open_api_v1_approval
condition: |
and
(
@@ -531,7 +542,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
- - open_api_approval
+ - open_api_beta_approval
condition: |
and
(
@@ -573,7 +584,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
- - open_api_approval
+ - open_api_beta_approval
condition: |
and
(
@@ -615,7 +626,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
- - open_api_approval
+ - open_api_v1_approval
condition: |
and
(
@@ -731,7 +742,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
- - open_api_approval
+ - open_api_v1_approval
condition: |
and
(
@@ -774,7 +785,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
- - open_api_approval
+ - open_api_beta_approval
condition: |
and
(
@@ -817,7 +828,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_v1_openapi
- - open_api_approval
+ - open_api_v1_approval
condition: |
and
(
@@ -858,7 +869,7 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
- - open_api_approval
+ - open_api_beta_approval
condition: |
and
(
@@ -899,7 +910,6 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
- - open_api_approval
condition: |
and
(
@@ -943,7 +953,6 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
- - open_api_approval
condition: |
and
(
@@ -987,7 +996,6 @@ extends:
dependsOn:
- stage_build_and_publish_kiota
- stage_beta_openapi
- - open_api_approval
condition: |
and
(