From c131ea89e1b692d514ed2d9be03e7144c322b18d Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 14 May 2024 04:18:16 +0800 Subject: [PATCH] Nuget Publish pipelines should be trigger by rel-* automatically too. (#20652) ### Description And Set allowPackageConflicts = True `#allowPackageConflicts: false # boolean. Optional. Use when command = push && nuGetFeedType = internal. Allow duplicates to be skipped. Default: false.` https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/nuget-command-v2?view=azure-pipelines Once the publish patial failed, we don't need to rerun the whole package generation workflow. --- .../github/azure-pipelines/publish-nuget.yml | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/publish-nuget.yml b/tools/ci_build/github/azure-pipelines/publish-nuget.yml index 19ede05eb12b..9f2797abc737 100644 --- a/tools/ci_build/github/azure-pipelines/publish-nuget.yml +++ b/tools/ci_build/github/azure-pipelines/publish-nuget.yml @@ -2,10 +2,11 @@ resources: pipelines: - pipeline: build source: 'Zip-Nuget-Java-Nodejs Packaging Pipeline' - trigger: + trigger: branches: include: - main + - rel-* branch: main stages: @@ -20,23 +21,28 @@ stages: pool: 'onnxruntime-Win-CPU-2022' steps: + # https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/resources-pipelines-pipeline?view=azure-pipelines#pipeline-resource-metadata-as-predefined-variables + - script: | + echo $(resources.pipeline.build.sourceBranch) + echo $(Build.Reason) + displayName: 'Print triggering sourceBranch Name in resources' + - checkout: self submodules: false - template: templates/set-version-number-variables-step.yml - + - script: mkdir "$(Build.BinariesDirectory)\nuget-artifact\final-package" - + - download: build displayName: 'Download Pipeline Artifact - Signed NuGet Package' artifact: 'drop-signed-nuget-CPU' - + - script: move "$(Pipeline.Workspace)\build\drop-signed-nuget-CPU\*" "$(Build.BinariesDirectory)\nuget-artifact\final-package" - template: nuget/templates/get-nuget-package-version-as-variable.yml parameters: packageFolder: '$(Build.BinariesDirectory)/nuget-artifact/final-package' - # TODO: the following step has no error checking - task: CmdLine@2 displayName: 'Post binary sizes to the dashboard database using command line' inputs: @@ -46,8 +52,8 @@ stages: echo processing nupkg SETLOCAL EnableDelayedExpansion FOR /R %%i IN (*.nupkg) do ( - set filename=%%~ni - IF NOT "!filename:~25,7!"=="Managed" ( + set filename=%%~ni + IF NOT "!filename:~25,7!"=="Managed" ( echo processing %%~ni.nupkg copy %%~ni.nupkg %%~ni.zip echo copied to zip @@ -61,10 +67,10 @@ stages: ) ) - # Only report binary sizes to database if the build build was auto-triggered from the main branch - task: AzureCLI@2 displayName: 'Azure CLI' - condition: and (succeeded(), and(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.Reason'], 'ResourceTrigger'))) + #Only report binary sizes to database if the build build was auto-triggered from the main branch + condition: and (succeeded(), and(eq(variables['resources.pipeline.build.sourceBranch'], 'refs/heads/main'), eq(variables['Build.Reason'], 'ResourceTrigger'))) inputs: azureSubscription: AIInfraBuildOnnxRuntimeOSS scriptLocation: inlineScript @@ -117,7 +123,7 @@ stages: - task: CodeSign@1 displayName: 'Run Codesign Validation' - + - task: PublishSecurityAnalysisLogs@3 displayName: 'Publish Security Analysis Logs' @@ -136,6 +142,7 @@ stages: command: 'push' packagesToPush: '$(Build.BinariesDirectory)/nuget-artifact/final-package/*.nupkg' publishVstsFeed: '2692857e-05ef-43b4-ba9c-ccf1c22c437c/7982ae20-ed19-4a35-a362-a96ac99897b7' + allowPackageConflicts: true - template: templates/component-governance-component-detection-steps.yml parameters :