From 7f8da5754e382fcc5d0992a3f72b17d4ee1e9b05 Mon Sep 17 00:00:00 2001 From: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:39:59 -0700 Subject: [PATCH] Setup internal feeds in internal builds (#90637) * Setup internal feeds in internal builds * Add 8 explicitly for now * Fix condition on mono-wasm workloads --- eng/common/SetupNugetSources.ps1 | 8 ++++---- eng/common/SetupNugetSources.sh | 6 +++--- eng/pipelines/common/global-build-job.yml | 19 +++++++++++++++++++ eng/pipelines/coreclr/templates/build-job.yml | 18 ++++++++++++++++++ eng/pipelines/libraries/base-job.yml | 19 +++++++++++++++++++ 5 files changed, 63 insertions(+), 7 deletions(-) diff --git a/eng/common/SetupNugetSources.ps1 b/eng/common/SetupNugetSources.ps1 index 6c65e81925f2a..2dc86ea2cdda1 100644 --- a/eng/common/SetupNugetSources.ps1 +++ b/eng/common/SetupNugetSources.ps1 @@ -2,7 +2,7 @@ # This file should be removed as part of this issue: https://github.com/dotnet/arcade/issues/4080 # # What the script does is iterate over all package sources in the pointed NuGet.config and add a credential entry -# under for each Maestro managed private feed. Two additional credential +# under for each Maestro managed private feed. Two additional credential # entries are also added for the two private static internal feeds: dotnet3-internal and dotnet3-internal-transport. # # This script needs to be called in every job that will restore packages and which the base repo has @@ -37,7 +37,7 @@ Set-StrictMode -Version 2.0 # Add source entry to PackageSources function AddPackageSource($sources, $SourceName, $SourceEndPoint, $creds, $Username, $Password) { $packageSource = $sources.SelectSingleNode("add[@key='$SourceName']") - + if ($packageSource -eq $null) { $packageSource = $doc.CreateElement("add") @@ -48,7 +48,7 @@ function AddPackageSource($sources, $SourceName, $SourceEndPoint, $creds, $Usern else { Write-Host "Package source $SourceName already present." } - + AddCredential -Creds $creds -Source $SourceName -Username $Username -Password $Password } @@ -89,7 +89,7 @@ function InsertMaestroPrivateFeedCredentials($Sources, $Creds, $Username, $Passw $maestroPrivateSources = $Sources.SelectNodes("add[contains(@key,'darc-int')]") Write-Host "Inserting credentials for $($maestroPrivateSources.Count) Maestro's private feeds." - + ForEach ($PackageSource in $maestroPrivateSources) { Write-Host "`tInserting credential for Maestro's feed:" $PackageSource.Key AddCredential -Creds $creds -Source $PackageSource.Key -Username $Username -Password $Password diff --git a/eng/common/SetupNugetSources.sh b/eng/common/SetupNugetSources.sh index d387c7eac95e5..a8bb8acd3be18 100644 --- a/eng/common/SetupNugetSources.sh +++ b/eng/common/SetupNugetSources.sh @@ -4,7 +4,7 @@ # This file should be removed as part of this issue: https://github.com/dotnet/arcade/issues/4080 # # What the script does is iterate over all package sources in the pointed NuGet.config and add a credential entry -# under for each Maestro's managed private feed. Two additional credential +# under for each Maestro's managed private feed. Two additional credential # entries are also added for the two private static internal feeds: dotnet3-internal and dotnet3-internal-transport. # # This script needs to be called in every job that will restore packages and which the base repo has @@ -68,7 +68,7 @@ if [ "$?" != "0" ]; then sed -i.bak "s|$ConfigNodeHeader|$ConfigNodeHeader${NL}$PackageSourcesTemplate|" $ConfigFile fi -# Ensure there is a ... section. +# Ensure there is a ... section. grep -i "" $ConfigFile if [ "$?" != "0" ]; then echo "Adding ... section." @@ -142,7 +142,7 @@ IFS=$PrevIFS for FeedName in ${PackageSources[@]} ; do # Check if there is no existing credential for this FeedName - grep -i "<$FeedName>" $ConfigFile + grep -i "<$FeedName>" $ConfigFile if [ "$?" != "0" ]; then echo "Adding credentials for $FeedName." diff --git a/eng/pipelines/common/global-build-job.yml b/eng/pipelines/common/global-build-job.yml index 943da73f42da8..373175858586f 100644 --- a/eng/pipelines/common/global-build-job.yml +++ b/eng/pipelines/common/global-build-job.yml @@ -68,6 +68,7 @@ jobs: variables: - ${{ if eq(variables['System.TeamProject'], 'internal') }}: - group: DotNet-HelixApi-Access + - group: AzureDevOps-Artifact-Feeds-Pats - name: _osParameter value: -os ${{ parameters.osGroup }} @@ -182,6 +183,24 @@ jobs: - ${{ if and(eq(parameters.isOfficialBuild, true), notin(parameters.osGroup, 'osx', 'maccatalyst', 'ios', 'iossimulator', 'tvos', 'tvossimulator')) }}: - template: /eng/pipelines/common/restore-internal-tools.yml + - ${{ if ne(variables['System.TeamProject'], 'public') }}: + - ${{ if and(ne(parameters.osGroup, 'windows'), ne(parameters.hostedOs, 'windows')) }}: + - task: Bash@3 + displayName: Setup Private Feeds Credentials + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh + arguments: $(Build.SourcesDirectory)/NuGet.config $Token + env: + Token: $(dn-bot-dnceng-artifact-feeds-rw) + - ${{ else }}: + - task: PowerShell@2 + displayName: Setup Private Feeds Credentials + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1 + arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $Env:Token + env: + Token: $(dn-bot-dnceng-artifact-feeds-rw) + - ${{ each monoCrossAOTTargetOS in parameters.monoCrossAOTTargetOS }}: - task: DownloadPipelineArtifact@2 displayName: Download ${{monoCrossAOTTargetOS}} AOT offset files diff --git a/eng/pipelines/coreclr/templates/build-job.yml b/eng/pipelines/coreclr/templates/build-job.yml index ff6abefba7e7e..9f196066f2794 100644 --- a/eng/pipelines/coreclr/templates/build-job.yml +++ b/eng/pipelines/coreclr/templates/build-job.yml @@ -143,6 +143,24 @@ jobs: continueOnError: false condition: and(succeeded(), in(variables['SignType'], 'real', 'test')) + - ${{ if ne(variables['System.TeamProject'], 'public') }}: + - ${{ if ne(parameters.osGroup, 'windows') }}: + - task: Bash@3 + displayName: Setup Private Feeds Credentials + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh + arguments: $(Build.SourcesDirectory)/NuGet.config $Token + env: + Token: $(dn-bot-dnceng-artifact-feeds-rw) + - ${{ if eq(parameters.osGroup, 'windows') }}: + - task: PowerShell@2 + displayName: Setup Private Feeds Credentials + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1 + arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $Env:Token + env: + Token: $(dn-bot-dnceng-artifact-feeds-rw) + - ${{ if in(parameters.osGroup, 'osx', 'ios', 'tvos') }}: - script: | du -sh $(Build.SourcesDirectory)/* diff --git a/eng/pipelines/libraries/base-job.yml b/eng/pipelines/libraries/base-job.yml index adf816379efe7..5053ddab2a5a3 100644 --- a/eng/pipelines/libraries/base-job.yml +++ b/eng/pipelines/libraries/base-job.yml @@ -49,6 +49,7 @@ jobs: variables: - ${{ if eq(variables['System.TeamProject'], 'internal') }}: - group: DotNet-HelixApi-Access + - group: AzureDevOps-Artifact-Feeds-Pats - _buildScriptFileName: build @@ -137,4 +138,22 @@ jobs: artifactName: '$(_runtimeArtifactName)' displayName: '$(runtimeFlavorName) build drop' + - ${{ if ne(variables['System.TeamProject'], 'public') }}: + - ${{ if ne(parameters.osGroup, 'windows') }}: + - task: Bash@3 + displayName: Setup Private Feeds Credentials + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh + arguments: $(Build.SourcesDirectory)/NuGet.config $Token + env: + Token: $(dn-bot-dnceng-artifact-feeds-rw) + - ${{ if eq(parameters.osGroup, 'windows') }}: + - task: PowerShell@2 + displayName: Setup Private Feeds Credentials + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1 + arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $Env:Token + env: + Token: $(dn-bot-dnceng-artifact-feeds-rw) + - ${{ parameters.steps }}