diff --git a/tools/ci_build/github/azure-pipelines/linux-gpu-tensorrt-cuda-minimal-ci-pipeline.yml b/tools/ci_build/github/azure-pipelines/linux-gpu-tensorrt-cuda-minimal-ci-pipeline.yml index 985a5c8b390b2..a062a1fce5c1b 100644 --- a/tools/ci_build/github/azure-pipelines/linux-gpu-tensorrt-cuda-minimal-ci-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/linux-gpu-tensorrt-cuda-minimal-ci-pipeline.yml @@ -67,10 +67,9 @@ jobs: clean: true submodules: none - - task: UsePythonVersion@0 - inputs: + - template: templates/setup-feeds-and-python-steps.yml + parameters: versionSpec: '3.12' - addToPath: true architecture: 'x64' - template: templates/get-docker-image-steps.yml diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml index 9c5c796d2983d..c40b8dbc6269d 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml @@ -37,15 +37,9 @@ stages: value: '-Dorg.gradle.daemon=false' steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.12' - addToPath: true - architecture: x64 - - task: PipAuthenticate@1 - displayName: 'Pip Authenticate' - inputs: - artifactFeeds: 'Lotus' + - template: ../../templates/setup-feeds-and-python-steps.yml + parameters: + architecture: 'x64' - task: NuGetToolInstaller@0 displayName: Use Nuget 6.10.x @@ -69,7 +63,7 @@ stages: - download: build displayName: 'Download Nuget' artifact: 'drop-signed-nuget-${{ parameters.ArtifactSuffix }}' - + - template: get-nuget-package-version-as-variable.yml parameters: diff --git a/tools/ci_build/github/azure-pipelines/post-merge-jobs.yml b/tools/ci_build/github/azure-pipelines/post-merge-jobs.yml index 50a219e183f08..ba7fa4e607646 100644 --- a/tools/ci_build/github/azure-pipelines/post-merge-jobs.yml +++ b/tools/ci_build/github/azure-pipelines/post-merge-jobs.yml @@ -398,11 +398,9 @@ stages: - checkout: self submodules: false - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.12' - addToPath: true - architecture: x64 + - template: templates/setup-feeds-and-python-steps.yml + parameters: + architecture: 'x64' - task: CmdLine@2 displayName: 'Run build_custom_android_package.py' @@ -432,11 +430,10 @@ stages: vmImage: "macOS-14" steps: - - task: UsePythonVersion@0 - inputs: + - template: templates/setup-feeds-and-python-steps.yml + parameters: versionSpec: "3.12" - addToPath: true - architecture: "x64" + architecture: 'x64' - template: templates/use-xcode-version.yml diff --git a/tools/ci_build/github/azure-pipelines/stages/jobs/react-natvie-andriod-e2e-test-job.yml b/tools/ci_build/github/azure-pipelines/stages/jobs/react-natvie-andriod-e2e-test-job.yml index 33f5dec2224a8..6ace0b904ad2a 100644 --- a/tools/ci_build/github/azure-pipelines/stages/jobs/react-natvie-andriod-e2e-test-job.yml +++ b/tools/ci_build/github/azure-pipelines/stages/jobs/react-natvie-andriod-e2e-test-job.yml @@ -23,12 +23,9 @@ jobs: ANDROID_AVD_HOME: $(Agent.TempDirectory) timeoutInMinutes: 90 steps: - - task: UsePythonVersion@0 - displayName: Use python 3.12 - inputs: - versionSpec: "3.12" - addToPath: true - architecture: "x64" + - template: ../../templates/setup-feeds-and-python-steps.yml + parameters: + architecture: 'x64' - task: JavaToolInstaller@0 displayName: Use jdk 17 diff --git a/tools/ci_build/github/azure-pipelines/stages/nuget-cuda-packaging-stage.yml b/tools/ci_build/github/azure-pipelines/stages/nuget-cuda-packaging-stage.yml index a0f578e22f910..79bbe39ce4af2 100644 --- a/tools/ci_build/github/azure-pipelines/stages/nuget-cuda-packaging-stage.yml +++ b/tools/ci_build/github/azure-pipelines/stages/nuget-cuda-packaging-stage.yml @@ -40,6 +40,9 @@ stages: steps: - checkout: self submodules: true + + - template: ../templates/setup-feeds-and-python-steps.yml + - template: ../templates/flex-downloadPipelineArtifact.yml parameters: StepName: 'Download Pipeline Artifact - NuGet' @@ -72,16 +75,6 @@ stages: SpecificArtifact: ${{ parameters.SpecificArtifact }} BuildId: ${{ parameters.BuildId }} - - task: UsePythonVersion@0 - displayName: 'Use Python' - inputs: - versionSpec: 3.12 - - - task: PipAuthenticate@1 - displayName: 'Pip Authenticate' - inputs: - artifactFeeds: 'Lotus' - - template: ../templates/set-version-number-variables-step.yml # Reconstruct the build dir diff --git a/tools/ci_build/github/azure-pipelines/stages/nuget-linux-cuda-packaging-stage.yml b/tools/ci_build/github/azure-pipelines/stages/nuget-linux-cuda-packaging-stage.yml index 0bce2a052ff1b..423e0d9691c55 100644 --- a/tools/ci_build/github/azure-pipelines/stages/nuget-linux-cuda-packaging-stage.yml +++ b/tools/ci_build/github/azure-pipelines/stages/nuget-linux-cuda-packaging-stage.yml @@ -30,11 +30,8 @@ stages: - name: CUDA_VERSION value: ${{ parameters.CudaVersion }} steps: + - template: ../templates/setup-feeds-and-python-steps.yml - template: ../templates/set-version-number-variables-step.yml - - task: UsePythonVersion@0 - displayName: Use Python 3.12 - inputs: - versionSpec: 3.12 - template: ../templates/get-docker-image-steps.yml parameters: Dockerfile: tools/ci_build/github/linux/docker/inference/x86_64/default/cuda${{ variables.CUDA_VERSION_MAJOR }}/Dockerfile @@ -90,10 +87,7 @@ stages: - checkout: self clean: true submodules: recursive - - task: UsePythonVersion@0 - displayName: Use Python 3.12 - inputs: - versionSpec: 3.12 + - template: ../templates/setup-feeds-and-python-steps.yml - template: ../templates/get-docker-image-steps.yml parameters: Dockerfile: tools/ci_build/github/linux/docker/inference/x86_64/default/cuda${{ variables.CUDA_VERSION_MAJOR }}/Dockerfile diff --git a/tools/ci_build/github/azure-pipelines/stages/nuget-win-cuda-packaging-stage.yml b/tools/ci_build/github/azure-pipelines/stages/nuget-win-cuda-packaging-stage.yml index ab23b96710a7e..7f2cb297f0251 100644 --- a/tools/ci_build/github/azure-pipelines/stages/nuget-win-cuda-packaging-stage.yml +++ b/tools/ci_build/github/azure-pipelines/stages/nuget-win-cuda-packaging-stage.yml @@ -127,6 +127,8 @@ stages: - checkout: onnxruntime-inference-examples # due to checkout multiple repos, the root directory is $(Build.SourcesDirectory)/onnxruntime-inference-examples submodules: false + - template: ../templates/setup-feeds-and-python-steps.yml + - script: dir $(Build.SourcesDirectory) - template: ../templates/jobs/download_win_gpu_library.yml parameters: diff --git a/tools/ci_build/github/azure-pipelines/stages/py-win-gpu-stage.yml b/tools/ci_build/github/azure-pipelines/stages/py-win-gpu-stage.yml index ab1432df2cbc2..45bc7db05592a 100644 --- a/tools/ci_build/github/azure-pipelines/stages/py-win-gpu-stage.yml +++ b/tools/ci_build/github/azure-pipelines/stages/py-win-gpu-stage.yml @@ -201,17 +201,11 @@ stages: clean: true submodules: none - - task: UsePythonVersion@0 - inputs: + - template: ../templates/setup-feeds-and-python-steps.yml + parameters: versionSpec: ${{ parameters.PYTHON_VERSION }} - addToPath: true architecture: 'x64' - - task: PipAuthenticate@1 - displayName: 'Pip Authenticate' - inputs: - artifactFeeds: 'Lotus' - - template: ../templates/jobs/download_win_gpu_library.yml parameters: CudaVersion: ${{ parameters.CudaVersion }} diff --git a/tools/ci_build/github/azure-pipelines/stages/py-win-webgpu-stage.yml b/tools/ci_build/github/azure-pipelines/stages/py-win-webgpu-stage.yml index 0d3357319dd53..742178e75b33d 100644 --- a/tools/ci_build/github/azure-pipelines/stages/py-win-webgpu-stage.yml +++ b/tools/ci_build/github/azure-pipelines/stages/py-win-webgpu-stage.yml @@ -155,17 +155,11 @@ stages: clean: true submodules: none - - task: UsePythonVersion@0 - inputs: + - template: ../templates/setup-feeds-and-python-steps.yml + parameters: versionSpec: ${{ parameters.PYTHON_VERSION }} - addToPath: true architecture: 'x64' - - task: PipAuthenticate@1 - displayName: 'Pip Authenticate' - inputs: - artifactFeeds: 'Lotus' - - script: python -m pip install -r $(Build.SourcesDirectory)\tools\ci_build\github\windows\python\requirements.txt env: TMPDIR: "$(Agent.TempDirectory)" diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml index 448dbafcaaaac..7b8b5758e79b5 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml @@ -348,16 +348,7 @@ stages: DisplayName: 'ESRP - Sign C# dlls' DoEsrp: true - - task: UsePythonVersion@0 - displayName: 'Use Python' - inputs: - versionSpec: 3.12 - - - task: PipAuthenticate@1 - displayName: 'Pip Authenticate' - inputs: - artifactFeeds: 'Lotus' - + - template: setup-feeds-and-python-steps.yml - task: MSBuild@1 displayName: 'Build Nuget Packages' diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-linux-cpu.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-linux-cpu.yml index 3f34e7ae37538..f22527bb2bd51 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-linux-cpu.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-linux-cpu.yml @@ -46,12 +46,10 @@ jobs: clean: true submodules: none - - ${{ if eq(parameters.OnnxruntimeArch, 'x64') }}: - # Only need to install Python on x64 agents as Python is pre-installed on arm64 agents - - task: UsePythonVersion@0 - displayName: Use Python 3.12 - inputs: - versionSpec: 3.12 + # Authenticate to Lotus to pull pip in UsePythonVersion task + - template: ../templates/setup-feeds-and-python-steps.yml + parameters: + architecture: ${{ parameters.OnnxruntimeArch }} - template: set-version-number-variables-step.yml - ${{ if eq(parameters.OnnxruntimeArch, 'x64') }}: diff --git a/tools/ci_build/github/azure-pipelines/templates/check_test_result.yml b/tools/ci_build/github/azure-pipelines/templates/check_test_result.yml index 22a233ba93e9d..c32beef2a8e44 100644 --- a/tools/ci_build/github/azure-pipelines/templates/check_test_result.yml +++ b/tools/ci_build/github/azure-pipelines/templates/check_test_result.yml @@ -3,18 +3,12 @@ parameters: type: string steps: - - task: UsePythonVersion@0 - inputs: + + - template: setup-feeds-and-python-steps.yml + parameters: versionSpec: '3.x' - addToPath: true architecture: 'x64' - - task: PipAuthenticate@1 - displayName: 'Pip Authenticate' - inputs: - artifactFeeds: 'Lotus' - - - task: PythonScript@0 displayName: 'Check test result yml' inputs: diff --git a/tools/ci_build/github/azure-pipelines/templates/foundry-local-nuget-packaging.yml b/tools/ci_build/github/azure-pipelines/templates/foundry-local-nuget-packaging.yml index 0ad230f835778..2d1c182ec7512 100644 --- a/tools/ci_build/github/azure-pipelines/templates/foundry-local-nuget-packaging.yml +++ b/tools/ci_build/github/azure-pipelines/templates/foundry-local-nuget-packaging.yml @@ -58,15 +58,7 @@ stages: artifactName: 'onnxruntime-osx' targetPath: '$(Build.BinariesDirectory)/osx' - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.12' - addToPath: true - - - task: PipAuthenticate@1 - displayName: 'Pip Authenticate' - inputs: - artifactFeeds: 'Lotus' + - template: setup-feeds-and-python-steps.yml - task: PowerShell@2 displayName: 'Create osx directories' diff --git a/tools/ci_build/github/azure-pipelines/templates/jar-maven-signing-linux.yml b/tools/ci_build/github/azure-pipelines/templates/jar-maven-signing-linux.yml index dd07fbad3e059..90bcafcc34aff 100644 --- a/tools/ci_build/github/azure-pipelines/templates/jar-maven-signing-linux.yml +++ b/tools/ci_build/github/azure-pipelines/templates/jar-maven-signing-linux.yml @@ -12,10 +12,7 @@ steps: SecretsFilter: "java-pgp-pwd,java-pgp-key" RunAsPreJob: false - - task: UsePythonVersion@0 - displayName: "Use Python 3.12" - inputs: - versionSpec: "3.12" + - template: setup-feeds-and-python-steps.yml - task: PythonScript@0 displayName: "Sign files: GnuPG, sha1, and md5" diff --git a/tools/ci_build/github/azure-pipelines/templates/jar-packaging.yml b/tools/ci_build/github/azure-pipelines/templates/jar-packaging.yml index 9d9065719458a..4d60544f5f8d9 100644 --- a/tools/ci_build/github/azure-pipelines/templates/jar-packaging.yml +++ b/tools/ci_build/github/azure-pipelines/templates/jar-packaging.yml @@ -15,15 +15,9 @@ steps: - checkout: self submodules: false -- task: UsePythonVersion@0 - inputs: +- template: setup-feeds-and-python-steps.yml + parameters: versionSpec: '3.13' - addToPath: true - -- task: PipAuthenticate@1 - displayName: 'Pip Authenticate' - inputs: - artifactFeeds: 'Lotus' - template: set-version-number-variables-step.yml diff --git a/tools/ci_build/github/azure-pipelines/templates/linux-wasm-ci.yml b/tools/ci_build/github/azure-pipelines/templates/linux-wasm-ci.yml index 97e7a43a88824..8eafeddf28f14 100644 --- a/tools/ci_build/github/azure-pipelines/templates/linux-wasm-ci.yml +++ b/tools/ci_build/github/azure-pipelines/templates/linux-wasm-ci.yml @@ -84,10 +84,9 @@ jobs: git submodule update --init --recursive workingDirectory: '$(Build.SourcesDirectory)' displayName: 'Checkout submodules' - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.12' - addToPath: true + - template: templates/setup-feeds-and-python-steps.yml + parameters: + versionSpec: "3.12" architecture: $(buildArch) - task: NodeTool@0 inputs: diff --git a/tools/ci_build/github/azure-pipelines/templates/make_java_win_binaries.yml b/tools/ci_build/github/azure-pipelines/templates/make_java_win_binaries.yml index d1ea61ada90c3..9568c2882bfe3 100644 --- a/tools/ci_build/github/azure-pipelines/templates/make_java_win_binaries.yml +++ b/tools/ci_build/github/azure-pipelines/templates/make_java_win_binaries.yml @@ -22,29 +22,35 @@ parameters: steps: - task: PowerShell@2 displayName: 'Build and Package Java Artifacts' + env: + msbuild_platform: ${{ parameters.msbuildPlatform }} + java_artifact_id: ${{ parameters.java_artifact_id }} + pre_release_version_suffix_string: ${{ parameters.PreReleaseVersionSuffixString }} + pre_release_version_suffix_number: ${{ parameters.PreReleaseVersionSuffixNumber }} + build_only: ${{ parameters.buildOnly }} inputs: targetType: 'inline' script: | # Define arguments for the Python script $scriptArgs = @( - "--sources-dir", "$(Build.SourcesDirectory)", - "--binaries-dir", "$(Build.BinariesDirectory)", - "--platform", "${{ parameters.msbuildPlatform }}", - "--build-config", "RelWithDebInfo", - "--java-artifact-id", "${{ parameters.java_artifact_id }}", - "--pre-release-version-suffix-string", "${{ parameters.PreReleaseVersionSuffixString }}", - "--pre-release-version-suffix-number", "${{ parameters.PreReleaseVersionSuffixNumber }}", - "--commit-hash", "$(OnnxRuntimeGitCommitHash)" + "--sources-dir", "${env:BUILD_SOURCESDIRECTORY}", + "--binaries-dir", "${env:BUILD_BINARIESDIRECTORY}", + "--platform", "${env:msbuild_platform}", + "--build-config", "RelWithDebInfo", + "--java-artifact-id", "${env:java_artifact_id}", + "--pre-release-version-suffix-string", "${env:pre_release_version_suffix_string}", + "--pre-release-version-suffix-number", "${env:pre_release_version_suffix_number}", + "--commit-hash", "${env:ONNXRUNTIMEGITCOMMITHASH}" ) # Conditionally add the --build-only flag if the parameter is true - if ('${{ parameters.buildOnly }}' -eq 'True') { + if (${env:build_only} -eq 'True') { $scriptArgs += "--build-only" } # Define the path to the python script within your repository - $scriptPath = "$(Build.SourcesDirectory)/tools/ci_build/manage_java_artifacts.py" + $scriptPath = "${env:BUILD_SOURCESDIRECTORY}/tools/ci_build/manage_java_artifacts.py" # Execute the Python script, passing all arguments Write-Host "Executing Python script: $scriptPath with arguments: $($scriptArgs -join ' ')" - python $scriptPath $scriptArgs \ No newline at end of file + python $scriptPath $scriptArgs diff --git a/tools/ci_build/github/azure-pipelines/templates/managed-nuget-for-foundry-local.yml b/tools/ci_build/github/azure-pipelines/templates/managed-nuget-for-foundry-local.yml index 681dcd4c33ab7..52e0046cd9b47 100644 --- a/tools/ci_build/github/azure-pipelines/templates/managed-nuget-for-foundry-local.yml +++ b/tools/ci_build/github/azure-pipelines/templates/managed-nuget-for-foundry-local.yml @@ -37,10 +37,7 @@ stages: steps: - template: set-version-number-variables-step.yml - - task: UsePythonVersion@0 - displayName: 'Use Python' - inputs: - versionSpec: 3.12 + - template: setup-feeds-and-python-steps.yml - task: DownloadPipelineArtifact@0 displayName: 'Download Pipeline Artifact - win-x64' diff --git a/tools/ci_build/github/azure-pipelines/templates/publish-nuget-steps.yml b/tools/ci_build/github/azure-pipelines/templates/publish-nuget-steps.yml index e1d63949efa9f..f26d5da7faaf7 100644 --- a/tools/ci_build/github/azure-pipelines/templates/publish-nuget-steps.yml +++ b/tools/ci_build/github/azure-pipelines/templates/publish-nuget-steps.yml @@ -30,10 +30,7 @@ stages: - checkout: self submodules: false - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.12' - addToPath: true + - template: setup-feeds-and-python-steps.yml - template: set-version-number-variables-step.yml @@ -130,5 +127,3 @@ stages: packageParentPath: '$(Build.BinariesDirectory)' publishVstsFeed: '2692857e-05ef-43b4-ba9c-ccf1c22c437c/7982ae20-ed19-4a35-a362-a96ac99897b7' allowPackageConflicts: true - - diff --git a/tools/ci_build/github/azure-pipelines/templates/py-package-smoking-test.yml b/tools/ci_build/github/azure-pipelines/templates/py-package-smoking-test.yml index 4ec074055fcc2..f5194d5c24047 100644 --- a/tools/ci_build/github/azure-pipelines/templates/py-package-smoking-test.yml +++ b/tools/ci_build/github/azure-pipelines/templates/py-package-smoking-test.yml @@ -37,9 +37,8 @@ jobs: steps: - checkout: none - - task: UsePythonVersion@0 - displayName: 'Use Python' - inputs: + - template: setup-feeds-and-python-steps.yml + parameters: versionSpec: $(PythonVersion) - download: build # pipeline resource identifier. diff --git a/tools/ci_build/github/azure-pipelines/templates/setup-build-tools.yml b/tools/ci_build/github/azure-pipelines/templates/setup-build-tools.yml index f9441a9b74c4a..93b39f3db058b 100644 --- a/tools/ci_build/github/azure-pipelines/templates/setup-build-tools.yml +++ b/tools/ci_build/github/azure-pipelines/templates/setup-build-tools.yml @@ -16,17 +16,11 @@ parameters: steps: - template: telemetry-steps.yml -- task: UsePythonVersion@0 - displayName: 'Use Python ${{ parameters.python_version }} ${{ parameters.host_cpu_arch }}' - inputs: +- template: setup-feeds-and-python-steps.yml + parameters: versionSpec: ${{ parameters.python_version }} architecture: ${{ parameters.host_cpu_arch }} -- task: PipAuthenticate@1 - displayName: 'Pip Authenticate' - inputs: - artifactFeeds: 'Lotus' - # The following task does not support different arches. - task: UseNode@1 condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) diff --git a/tools/ci_build/github/azure-pipelines/templates/setup-feeds-and-python-steps.yml b/tools/ci_build/github/azure-pipelines/templates/setup-feeds-and-python-steps.yml new file mode 100644 index 0000000000000..50628ad617d56 --- /dev/null +++ b/tools/ci_build/github/azure-pipelines/templates/setup-feeds-and-python-steps.yml @@ -0,0 +1,146 @@ +# Template for setting up the package feeds and installing python. +# Feeds configured: +# - pip +# - maven & gradle +# - nuget +# +# FIXME: Not idempotent. + +parameters: +- name: artifactFeeds + type: string + default: 'Lotus' + +- name: versionSpec + type: string + default: '3.12' + +- name: architecture + type: string + default: '' + +steps: +- task: NuGetAuthenticate@1 # just auth w/ internal feeds + +- task: MavenAuthenticate@0 + inputs: + artifactsFeeds: ${{ parameters.artifactFeeds }} + +- task: PipAuthenticate@1 + displayName: 'Pip Authenticate' + inputs: + artifactFeeds: ${{ parameters.artifactFeeds }} + +- task: UsePythonVersion@0 + displayName: 'Use Python ${{ parameters.versionSpec }}' + # aarch64 (aka arm64) is not currently available (2026-04-09). Skip installation. + # We'll be verifying the requested version of python is already installed below. + condition: ne('${{ parameters.architecture }}', 'aarch64') + inputs: + versionSpec: ${{ parameters.versionSpec }} + ${{ if ne(parameters.architecture, '') }}: + architecture: ${{ parameters.architecture }} + +- pwsh: | + # Check if python is available in PATH + $pythonCmd = Get-Command "python${env:python_version_spec}" -ErrorAction SilentlyContinue + if ($pythonCmd) { + Write-Host "Found `python${env:python_version_spec}` at $($pythonCmd.Source)" + exit 0 + } + + $pythonCmd = Get-Command "python" -ErrorAction SilentlyContinue + if ($pythonCmd) { + Write-Host "Found `python` at $($pythonCmd.Source)." + # FUTURE WORK: validate it matches the requested version spec + exit 0 + } + + Write-Host "##vso[task.logissue type=error]Neither `python` nor `python${env:python_version_spec}` are on PATH." + exit 1 + displayName: 'Verify Python ${{ parameters.versionSpec }} is on path' + env: + python_version_spec: ${{ parameters.versionSpec }} + +- pwsh: | + # Force everything to go through & authenticate using the main feed. + # ASSUME: there is no `mirrors` section already present in the settings.xml. + # HACK: Does not escape `parameters.artifactFeeds`. Assumes pattern is [A-Za-z0-9]+. + # HACK: Assumes feed is a org-scoped feed in `aiinfra`. + (Get-Content ~/.m2/settings.xml) | ` + %{ $_ -replace '', "${env:central_maven_feed_name}1ES Feed Overridehttps://aiinfra.pkgs.visualstudio.com/_packaging/${env:central_maven_feed_name}/maven/v1*" } | ` + Set-Content ~/.m2/settings.xml + + # gradle - inject 1ES feed repo into all projects/buildscripts. Auth using creds from maven settings.xml. + $gradleInitDir = if ($env:GRADLE_HOME_DIR) { $env:GRADLE_HOME_DIR } else { "~/.gradle" } + if (!(Test-Path -Path "${gradleInitDir}/init.d")) { + New-Item -ItemType Directory -Path "${gradleInitDir}/init.d" + } + Set-Content -Path "${gradleInitDir}/init.d/1es-feed-inject.init.gradle" -Value @" + // Use official 1ES feed. Network isolation prevents us from reaching out directly to other feeds. + + def mavenSettingsServers = { + File mavenSettings = new File(System.getProperty("user.home"), ".m2/settings.xml") + return new XmlSlurper().parse(mavenSettings)."servers"."server" + } + + def oneEsFeedCredentials = { + for (x in mavenSettingsServers()) { + if (x."id".text() == "${env:central_maven_feed_name}") { + return [username: x.username.text(), password: x.password.text()] + } + } + } + + allprojects { + buildscript { + repositories { + maven { + name "1ES Feed" + url uri("https://aiinfra.pkgs.visualstudio.com/_packaging/${env:central_maven_feed_name}/maven/v1") + credentials(PasswordCredentials) { + username oneEsFeedCredentials().username + password oneEsFeedCredentials().password + } + } + } + } + + repositories { + maven { + name "1ES Feed" + url uri("https://aiinfra.pkgs.visualstudio.com/_packaging/${env:central_maven_feed_name}/maven/v1") + credentials(PasswordCredentials) { + username oneEsFeedCredentials().username + password oneEsFeedCredentials().password + } + } + } + } + "@ + displayName: 'Maven/Gradle - mirror / feed via `${{ parameters.artifactFeeds }}`' + env: + central_maven_feed_name: ${{ parameters.artifactFeeds }} + +- pwsh: | + # NuGet appears to fail if any of the pkg sources are unreachable. + # Replace the NuGet.config w/ one that only has the internal feed. + # HACK: We'd rather splice the structure, not override the file. + Set-Content -Path "NuGet.config" -Value @" + + + + + + + + + + + + + + "@ + displayName: NuGet - override `NuGet.config` to lock feed to `${{ parameters.artifactFeeds }}` + env: + central_maven_feed_name: ${{ parameters.artifactFeeds }} diff --git a/tools/ci_build/github/azure-pipelines/templates/validate-package.yml b/tools/ci_build/github/azure-pipelines/templates/validate-package.yml index 950a5a6a34f4d..8332c3c60a7e1 100644 --- a/tools/ci_build/github/azure-pipelines/templates/validate-package.yml +++ b/tools/ci_build/github/azure-pipelines/templates/validate-package.yml @@ -9,11 +9,6 @@ parameters: workingDirectory: "$(Build.BinariesDirectory)" steps: - - task: UsePythonVersion@0 - displayName: 'Use Python' - inputs: - versionSpec: 3.12 - - task: PythonScript@0 displayName: 'Validate Package' inputs: diff --git a/tools/ci_build/github/azure-pipelines/templates/win-wasm-ci.yml b/tools/ci_build/github/azure-pipelines/templates/win-wasm-ci.yml index 9166f2de85c32..b9099e001a3d5 100644 --- a/tools/ci_build/github/azure-pipelines/templates/win-wasm-ci.yml +++ b/tools/ci_build/github/azure-pipelines/templates/win-wasm-ci.yml @@ -71,10 +71,8 @@ jobs: git submodule update --init --recursive workingDirectory: '$(Build.SourcesDirectory)' displayName: 'Checkout submodules' - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.12' - addToPath: true + - template: setup-feeds-and-python-steps.yml + parameters: architecture: $(buildArch) - task: NodeTool@0 inputs: