Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 953b929

Browse files
Sync eng/common directory with azure-sdk-tools for PR 9698 (Azure#32439)
* Fix pipeline generation for private repos * Update eng/common/pipelines/templates/steps/sparse-checkout.yml --------- Co-authored-by: Wes Haggard <[email protected]>
1 parent 198ffdb commit 953b929

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

eng/common/pipelines/templates/jobs/prepare-pipelines.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,21 @@ jobs:
5050
- '!sdk/**/recordings/*'
5151
- '!sdk/**/SessionRecords/*'
5252
- '!sdk/**/session-records/*'
53+
${{ if endsWith(parameters.Repository, '-pr') }}:
54+
TokenToUseForAuth: $(azuresdk-github-pat)
55+
5356
- template: /eng/common/pipelines/templates/steps/install-pipeline-generation.yml
5457
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml
5558

5659
- pwsh: |
5760
Write-Host "Setting up pipeline variables"
58-
if ("${{ parameters.Repository }}" -match "Azure/azure-sdk-for-(?<prefix>[^-]*)(?<pr>-pr)?") {
59-
$prefix = $matches['prefix']
60-
$devOpsPath = "\$prefix"
61+
if ("${{ parameters.Repository }}" -match "Azure/azure-sdk-for-(?<lang>[^-]*)(?<pr>-pr)?") {
62+
$lang = $matches['lang']
63+
$devOpsPath = "\$lang"
64+
$prefix = $lang
6165
if ($matches['pr']) {
6266
$devOpsPath = "${devOpsPath}\pr"
63-
$prefix = "${prefix}-pr"
67+
$prefix += "-pr"
6468
Write-Host "##vso[task.setvariable variable=ProjectForPRValidation]internal"
6569
}
6670
Write-Host "Prefix = $prefix"
@@ -79,8 +83,8 @@ jobs:
7983
$testServiceConnections = '"Azure" "azure-sdk-tests" "azure-sdk-tests-preview" "azure-sdk-tests-public" "Azure SDK Test Resources - LiveTestSecrets"'
8084
$internalServiceConnections = '"Azure" "Azure SDK Artifacts" "Azure SDK Engineering System" "opensource-api-connection" "AzureSDKEngKeyVault Secrets"'
8185
82-
# Map the language prefix to the appropriate variable groups
83-
switch ($prefix)
86+
# Map the language to the appropriate variable groups
87+
switch ($lang)
8488
{
8589
"java" {
8690
$internalVariableGroups = '$(AzureSDK_Maven_Release_Pipeline_Secrets) $(Release_Secrets_for_GitHub) $(APIReview_AutoCreate_Configurations)'
@@ -115,7 +119,7 @@ jobs:
115119
$generateUnifiedWeekly = 'true'
116120
}
117121
default {
118-
Write-Error "Prefix '$prefix' is not recognized."
122+
Write-Error "Language '$lang' is not recognized."
119123
exit 1
120124
}
121125
}

eng/common/pipelines/templates/steps/sparse-checkout.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,21 @@ parameters:
1111
- name: SkipCheckoutNone
1212
type: boolean
1313
default: false
14+
- name: TokenToUseForAuth
15+
type: string
16+
default: ''
1417

1518
steps:
1619
- ${{ if not(parameters.SkipCheckoutNone) }}:
1720
- checkout: none
1821

22+
- ${{ if ne(parameters.TokenToUseForAuth, '') }}:
23+
- pwsh: |
24+
$base64Token = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nobody:${{ parameters.TokenToUseForAuth }}"))
25+
Write-Host "##vso[task.setvariable variable=_base64AuthToken;issecret=true;]$base64Token"
26+
git config set --global "http.extraheader" "AUTHORIZATION: basic $base64Token"
27+
displayName: Setup git config auth header
28+
1929
- task: PowerShell@2
2030
${{ if eq(length(parameters.Repositories), 1) }}:
2131
displayName: 'Sparse checkout ${{ parameters.Repositories[0].Name }}'
@@ -126,3 +136,9 @@ steps:
126136
}
127137
pwsh: true
128138
workingDirectory: $(System.DefaultWorkingDirectory)
139+
140+
- ${{ if ne(parameters.TokenToUseForAuth, '') }}:
141+
- pwsh: |
142+
git config unset --global "http.extraheader"
143+
displayName: Removing git config auth header
144+
condition: always()

eng/common/pipelines/templates/steps/validate-all-packages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ parameters:
44
ConfigFileDir: $(Build.ArtifactStagingDirectory)/PackageInfo
55

66
steps:
7-
- ${{ if and(ne(variables['Skip.PackageValidation'], 'true'), eq(variables['System.TeamProject'], 'internal')) }}:
7+
- ${{ if and(ne(variables['Skip.PackageValidation'], 'true'), and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))) }}:
88
- pwsh: |
99
echo "##vso[task.setvariable variable=SetAsReleaseBuild]false"
1010
displayName: "Set as release build"

0 commit comments

Comments
 (0)