From c4bb9680b3e103b433b954bcb752986304e73e76 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 24 Feb 2021 16:18:26 -0800 Subject: [PATCH 01/24] Continue On Error to unblock people fixing other issues. --- eng/pipelines/aggregate-reports.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/pipelines/aggregate-reports.yml b/eng/pipelines/aggregate-reports.yml index 3fcb787b96f0..8428cc7c0af8 100644 --- a/eng/pipelines/aggregate-reports.yml +++ b/eng/pipelines/aggregate-reports.yml @@ -125,6 +125,7 @@ jobs: # GdnBreakOutputBaselineFile: java # GdnBreakOutputBaseline: baseline condition: succeededOrFailed() + continueOnError: true # Run link verification at the end as it will run no matter the pipeline passing or failing. # If this task fails with an error it shouldn't prevent aggregate reports from being generated. - template: ../common/pipelines/templates/steps/verify-links.yml From 71f4902b6810abea6e70993a76658248aff464a1 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 10:25:50 -0800 Subject: [PATCH 02/24] for testing --- eng/common/pipelines/templates/steps/verify-links.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index 1990ffe07dba..253b4b6fa046 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -6,7 +6,8 @@ parameters: Recursive: $false CheckLinkGuidance: $true Urls: '(Get-ChildItem -Path ./ -Recurse -Include *.md)' - BranchReplaceRegex: "^(${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)master(/.*)$" + BranchReplaceRegex: "^(${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)((git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1') +(/.*)$" BranchReplacementName: "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" Condition: succeeded() # If you want to run on failure for the link checker, set it to `Condition: succeededOrFailed()`. From e60825d4c3d697accb7eb83c3647f5d2b5994ca0 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 10:27:34 -0800 Subject: [PATCH 03/24] for testing1 --- eng/common/pipelines/templates/steps/verify-links.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index 253b4b6fa046..87ae9301f731 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -6,7 +6,7 @@ parameters: Recursive: $false CheckLinkGuidance: $true Urls: '(Get-ChildItem -Path ./ -Recurse -Include *.md)' - BranchReplaceRegex: "^(${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)((git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1') + BranchReplaceRegex: "^(${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)(git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' (/.*)$" BranchReplacementName: "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" Condition: succeeded() # If you want to run on failure for the link checker, set it to `Condition: succeededOrFailed()`. From 5ff04482383fb9dffca75835b0f5940bfd2d6f05 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 14:52:22 -0800 Subject: [PATCH 04/24] testing on daily-dev --- eng/common/pipelines/templates/steps/verify-links.yml | 3 +-- eng/pipelines/templates/jobs/archetype-sdk-client.yml | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index 87ae9301f731..ebfe105433d5 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -6,8 +6,7 @@ parameters: Recursive: $false CheckLinkGuidance: $true Urls: '(Get-ChildItem -Path ./ -Recurse -Include *.md)' - BranchReplaceRegex: "^(${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)(git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' -(/.*)$" + BranchReplaceRegex: "^(${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)($DefaultBranch)(/.*)$" BranchReplacementName: "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" Condition: succeeded() # If you want to run on failure for the link checker, set it to `Condition: succeededOrFailed()`. diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 42452dcf6f90..d013adc5917a 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -192,7 +192,10 @@ jobs: pip install doc-warden==$(DocWardenVersion) ward scan -d $(Build.SourcesDirectory) -c $(Build.SourcesDirectory)/eng/.docsettings.yml displayName: 'Verify Readmes' - + + - template: /eng/common/pipelines/templates/steps/daily-dev-build-variable.yml + parameters: + ServiceDirectory: ${{parameters.ServiceDirectory}} - template: /eng/common/pipelines/templates/steps/verify-links.yml parameters: ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: From 883626735c4b62df1993eb3fdb151b824f36c531 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 15:05:15 -0800 Subject: [PATCH 05/24] Added default branch variable --- .../templates/steps/daily-dev-build-variable.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml index a2c37ab5b81c..cc048cce10f3 100644 --- a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -22,3 +22,12 @@ steps: echo "##vso[task.setvariable variable=SetDevVersion]$setDailyDevBuild" displayName: "Setup Versioning Properties" condition: eq(variables['SetDevVersion'], '') +- pwsh: | + $setDefaultBranch = "master" + if (('$(Build.Reason)' -eq 'Schedule') -and ('$(System.TeamProject)' -eq 'internal')) { + $setDefaultBranch = (git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' + Write-Host $setDefaultBranch + } + echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" + displayName: "Setup Default Branch" + condition: eq(variables['DefaultBranch'], '') From b338b06b09395e56cfca8ce72140f5943820ce1c Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 15:16:01 -0800 Subject: [PATCH 06/24] Logging out --- eng/common/scripts/Verify-Links.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/common/scripts/Verify-Links.ps1 b/eng/common/scripts/Verify-Links.ps1 index 18aedd447da9..d1dbb085a3a7 100644 --- a/eng/common/scripts/Verify-Links.ps1 +++ b/eng/common/scripts/Verify-Links.ps1 @@ -278,7 +278,8 @@ function GetLinks([System.Uri]$pageUri) return $links; } - +Write-Host "Here is the place to look into default branch." +Write-Host $branchReplaceRegex if ($urls) { if ($urls.Count -eq 0) { Write-Host "Usage $($MyInvocation.MyCommand.Name) "; From 097889efbd79541a1f295e2fdbaf425cc0018ddc Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 15:16:51 -0800 Subject: [PATCH 07/24] Logging the meesage out --- eng/pipelines/aggregate-reports.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/eng/pipelines/aggregate-reports.yml b/eng/pipelines/aggregate-reports.yml index 8428cc7c0af8..b4a4f775d91d 100644 --- a/eng/pipelines/aggregate-reports.yml +++ b/eng/pipelines/aggregate-reports.yml @@ -103,6 +103,13 @@ jobs: # Only run if building all libraries succeeded. condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) displayName: 'Component Detection' + # Run link verification at the end as it will run no matter the pipeline passing or failing. + # If this task fails with an error it shouldn't prevent aggregate reports from being generated. + - template: ../common/pipelines/templates/steps/verify-links.yml + parameters: + Directory: "" + CheckLinkGuidance: $true + Condition: succeededOrFailed() # Put cred scan step before install and build packages to avoid the tool scans generated folder like /target. - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3 @@ -126,10 +133,3 @@ jobs: # GdnBreakOutputBaseline: baseline condition: succeededOrFailed() continueOnError: true - # Run link verification at the end as it will run no matter the pipeline passing or failing. - # If this task fails with an error it shouldn't prevent aggregate reports from being generated. - - template: ../common/pipelines/templates/steps/verify-links.yml - parameters: - Directory: "" - CheckLinkGuidance: $true - Condition: succeededOrFailed() From 78c852588a08eb911ce6362e4492cd984fb24116 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 15:31:21 -0800 Subject: [PATCH 08/24] 1 --- .../pipelines/templates/steps/daily-dev-build-variable.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml index cc048cce10f3..e77577cf6340 100644 --- a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -29,5 +29,6 @@ steps: Write-Host $setDefaultBranch } echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" + Write-Host $DefaultBranch displayName: "Setup Default Branch" condition: eq(variables['DefaultBranch'], '') From f3688e53baf0632c1ba914eab25ae585c485f4b9 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 15:41:10 -0800 Subject: [PATCH 09/24] 2 --- .../pipelines/templates/steps/daily-dev-build-variable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml index e77577cf6340..9c769bf7e515 100644 --- a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -29,6 +29,6 @@ steps: Write-Host $setDefaultBranch } echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" - Write-Host $DefaultBranch + Write-Host $(DefaultBranch) displayName: "Setup Default Branch" condition: eq(variables['DefaultBranch'], '') From b6e84a6cb06901963125a4006948c7949b05123b Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 15:55:39 -0800 Subject: [PATCH 10/24] 3 --- .../pipelines/templates/steps/daily-dev-build-variable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml index 9c769bf7e515..5961c04ce7f2 100644 --- a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -29,6 +29,6 @@ steps: Write-Host $setDefaultBranch } echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" - Write-Host $(DefaultBranch) + Write-Host "$(DefaultBranch)" displayName: "Setup Default Branch" condition: eq(variables['DefaultBranch'], '') From 82764e3764c98e5783379986c911c8742abdd754 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 16:12:57 -0800 Subject: [PATCH 11/24] 4 --- .../pipelines/templates/steps/daily-dev-build-variable.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml index 5961c04ce7f2..76d17be22750 100644 --- a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -29,6 +29,8 @@ steps: Write-Host $setDefaultBranch } echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" - Write-Host "$(DefaultBranch)" displayName: "Setup Default Branch" condition: eq(variables['DefaultBranch'], '') +- script: | + Write-Host "$(DefaultBranch)" + displayName: Display the default branch \ No newline at end of file From 35cecb6946e43fe3c07f51e1265c1f303cff9045 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 16:31:46 -0800 Subject: [PATCH 12/24] 5 --- .../pipelines/templates/steps/daily-dev-build-variable.yml | 4 ++-- eng/common/pipelines/templates/steps/verify-links.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml index 76d17be22750..281e7d94aaf5 100644 --- a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -32,5 +32,5 @@ steps: displayName: "Setup Default Branch" condition: eq(variables['DefaultBranch'], '') - script: | - Write-Host "$(DefaultBranch)" - displayName: Display the default branch \ No newline at end of file + Write-Host "$(DefaultBranch)" + displayName: Display the default branch \ No newline at end of file diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index ebfe105433d5..3ca82467f862 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -6,7 +6,7 @@ parameters: Recursive: $false CheckLinkGuidance: $true Urls: '(Get-ChildItem -Path ./ -Recurse -Include *.md)' - BranchReplaceRegex: "^(${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)($DefaultBranch)(/.*)$" + BranchReplaceRegex: "$(DefaultBranch)" BranchReplacementName: "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" Condition: succeeded() # If you want to run on failure for the link checker, set it to `Condition: succeededOrFailed()`. From ac28f4e0cea8bc8076254305c7eb27f79d3d7dfd Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 16:40:37 -0800 Subject: [PATCH 13/24] 6 --- .../pipelines/templates/steps/daily-dev-build-variable.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml index 281e7d94aaf5..6649ddad476b 100644 --- a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -30,7 +30,4 @@ steps: } echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" displayName: "Setup Default Branch" - condition: eq(variables['DefaultBranch'], '') -- script: | - Write-Host "$(DefaultBranch)" - displayName: Display the default branch \ No newline at end of file + condition: eq(variables['DefaultBranch'], '') \ No newline at end of file From a7283aa131e105d35fb3456df86eef34dbbf2c93 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 3 Mar 2021 18:17:22 -0800 Subject: [PATCH 14/24] 7 --- eng/common/pipelines/templates/steps/verify-links.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index 3ca82467f862..ebb1258249b4 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -6,7 +6,7 @@ parameters: Recursive: $false CheckLinkGuidance: $true Urls: '(Get-ChildItem -Path ./ -Recurse -Include *.md)' - BranchReplaceRegex: "$(DefaultBranch)" + BranchReplaceRegex: "(^${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)$(DefaultBranch)(/.*)$" BranchReplacementName: "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" Condition: succeeded() # If you want to run on failure for the link checker, set it to `Condition: succeededOrFailed()`. From a38d97204e8134d0eabd991e80fb696f0d9c4432 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 4 Mar 2021 09:06:42 -0800 Subject: [PATCH 15/24] 8 --- eng/common/pipelines/templates/steps/verify-links.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index ebb1258249b4..22b31043a9c8 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -6,11 +6,12 @@ parameters: Recursive: $false CheckLinkGuidance: $true Urls: '(Get-ChildItem -Path ./ -Recurse -Include *.md)' - BranchReplaceRegex: "(^${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)$(DefaultBranch)(/.*)$" - BranchReplacementName: "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" Condition: succeeded() # If you want to run on failure for the link checker, set it to `Condition: succeededOrFailed()`. steps: + - template: /eng/common/pipelines/templates/steps/daily-dev-build-variable.yml + parameters: + ServiceDirectory: ${{parameters.Directory}} - task: PowerShell@2 displayName: Link verification check condition: ${{ parameters.Condition }} @@ -23,7 +24,7 @@ steps: -rootUrl "file://${{ parameters.WorkingDirectory }}/${{ parameters.Directory }}" -recursive: ${{ parameters.Recursive }} -ignoreLinksFile ${{ parameters.IgnoreLinksFile }} - -branchReplaceRegex "${{ parameters.BranchReplaceRegex }}" - -branchReplacementName ${{ parameters.BranchReplacementName }} + -branchReplaceRegex "(^${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)$(DefaultBranch)(/.*)$" + -branchReplacementName "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" -devOpsLogging: $true -checkLinkGuidance: ${{ parameters.CheckLinkGuidance }} From d9039772614e34534ccd6c7a9696dd35c3797223 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 4 Mar 2021 09:07:00 -0800 Subject: [PATCH 16/24] 9 --- eng/pipelines/templates/jobs/archetype-sdk-client.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index d013adc5917a..42452dcf6f90 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -192,10 +192,7 @@ jobs: pip install doc-warden==$(DocWardenVersion) ward scan -d $(Build.SourcesDirectory) -c $(Build.SourcesDirectory)/eng/.docsettings.yml displayName: 'Verify Readmes' - - - template: /eng/common/pipelines/templates/steps/daily-dev-build-variable.yml - parameters: - ServiceDirectory: ${{parameters.ServiceDirectory}} + - template: /eng/common/pipelines/templates/steps/verify-links.yml parameters: ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: From fc384e3e379a0d4708386197b82f57779030f925 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 4 Mar 2021 09:12:28 -0800 Subject: [PATCH 17/24] 10 --- eng/pipelines/templates/jobs/archetype-sdk-client.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 42452dcf6f90..0eb801909dda 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -201,7 +201,7 @@ jobs: ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: Directory: sdk/${{ parameters.ServiceDirectory }} CheckLinkGuidance: $true - + Condition: succeededOrFailed() # Use BasePathLength of 38 instead of the default 49 as some GA'd files fail when the number is higher. - template: /eng/common/pipelines/templates/steps/verify-path-length.yml parameters: From 7060301be016ffe73fbc5f10246eb18f72c7ec5a Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 4 Mar 2021 09:41:14 -0800 Subject: [PATCH 18/24] 11 --- .../templates/steps/verify-links.yml | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index 22b31043a9c8..d68e34f80248 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -7,11 +7,15 @@ parameters: CheckLinkGuidance: $true Urls: '(Get-ChildItem -Path ./ -Recurse -Include *.md)' Condition: succeeded() # If you want to run on failure for the link checker, set it to `Condition: succeededOrFailed()`. - + BranchReplaceRegex: '' + BranchReplacementName: '' steps: - - template: /eng/common/pipelines/templates/steps/daily-dev-build-variable.yml - parameters: - ServiceDirectory: ${{parameters.Directory}} + - pwsh: | + $setDefaultBranch = (git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' + Write-Host $setDefaultBranch + echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" + displayName: "Setup Default Branch" + condition: eq(variables['DefaultBranch'], '') - task: PowerShell@2 displayName: Link verification check condition: ${{ parameters.Condition }} @@ -24,7 +28,11 @@ steps: -rootUrl "file://${{ parameters.WorkingDirectory }}/${{ parameters.Directory }}" -recursive: ${{ parameters.Recursive }} -ignoreLinksFile ${{ parameters.IgnoreLinksFile }} - -branchReplaceRegex "(^${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)$(DefaultBranch)(/.*)$" - -branchReplacementName "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" + - ${{ if eq(${{ parameters.BranchReplaceRegex }}, '') }}: + -branchReplaceRegex "(^${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)$(DefaultBranch)(/.*)$" + -branchReplacementName "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" + - ${{ if ne(${{ parameters.BranchReplaceRegex }}, '') }}: + -branchReplaceRegex ${{ parameters.BranchReplaceRegex }} + -branchReplacementName ${{ parameters.BranchReplacementName }} -devOpsLogging: $true - -checkLinkGuidance: ${{ parameters.CheckLinkGuidance }} + -checkLinkGuidance: ${{ parameters.CheckLinkGuidance }} \ No newline at end of file From 63828183b6fbe028b3c3c34cce2b33074461e956 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 4 Mar 2021 09:43:08 -0800 Subject: [PATCH 19/24] 12 --- eng/common/pipelines/templates/steps/verify-links.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index d68e34f80248..a2e7f8c86220 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -28,10 +28,10 @@ steps: -rootUrl "file://${{ parameters.WorkingDirectory }}/${{ parameters.Directory }}" -recursive: ${{ parameters.Recursive }} -ignoreLinksFile ${{ parameters.IgnoreLinksFile }} - - ${{ if eq(${{ parameters.BranchReplaceRegex }}, '') }}: + - ${{ if eq(eq(variables['Build.Reason'], 'PullRequest')) }}: -branchReplaceRegex "(^${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)$(DefaultBranch)(/.*)$" -branchReplacementName "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" - - ${{ if ne(${{ parameters.BranchReplaceRegex }}, '') }}: + - ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: -branchReplaceRegex ${{ parameters.BranchReplaceRegex }} -branchReplacementName ${{ parameters.BranchReplacementName }} -devOpsLogging: $true From 5eef828d829fc48cb2b792730cbb7cde6e456c0f Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 4 Mar 2021 09:52:13 -0800 Subject: [PATCH 20/24] 13 --- .../templates/steps/daily-dev-build-variable.yml | 9 --------- eng/common/pipelines/templates/steps/verify-links.yml | 11 +++-------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml index 6649ddad476b..a2c37ab5b81c 100644 --- a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -22,12 +22,3 @@ steps: echo "##vso[task.setvariable variable=SetDevVersion]$setDailyDevBuild" displayName: "Setup Versioning Properties" condition: eq(variables['SetDevVersion'], '') -- pwsh: | - $setDefaultBranch = "master" - if (('$(Build.Reason)' -eq 'Schedule') -and ('$(System.TeamProject)' -eq 'internal')) { - $setDefaultBranch = (git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' - Write-Host $setDefaultBranch - } - echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" - displayName: "Setup Default Branch" - condition: eq(variables['DefaultBranch'], '') \ No newline at end of file diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index a2e7f8c86220..9c807f9f643d 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -7,8 +7,7 @@ parameters: CheckLinkGuidance: $true Urls: '(Get-ChildItem -Path ./ -Recurse -Include *.md)' Condition: succeeded() # If you want to run on failure for the link checker, set it to `Condition: succeededOrFailed()`. - BranchReplaceRegex: '' - BranchReplacementName: '' + steps: - pwsh: | $setDefaultBranch = (git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' @@ -28,11 +27,7 @@ steps: -rootUrl "file://${{ parameters.WorkingDirectory }}/${{ parameters.Directory }}" -recursive: ${{ parameters.Recursive }} -ignoreLinksFile ${{ parameters.IgnoreLinksFile }} - - ${{ if eq(eq(variables['Build.Reason'], 'PullRequest')) }}: - -branchReplaceRegex "(^${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)$(DefaultBranch)(/.*)$" - -branchReplacementName "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" - - ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: - -branchReplaceRegex ${{ parameters.BranchReplaceRegex }} - -branchReplacementName ${{ parameters.BranchReplacementName }} + -branchReplaceRegex "(^${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)$(DefaultBranch)(/.*)$" + -branchReplacementName "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" -devOpsLogging: $true -checkLinkGuidance: ${{ parameters.CheckLinkGuidance }} \ No newline at end of file From 01f5c0560b128ca200192cbac32d168a3eb1478b Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 4 Mar 2021 15:37:40 -0800 Subject: [PATCH 21/24] 14 --- eng/common/pipelines/templates/steps/verify-links.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index 9c807f9f643d..396ac7fb8412 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -6,6 +6,8 @@ parameters: Recursive: $false CheckLinkGuidance: $true Urls: '(Get-ChildItem -Path ./ -Recurse -Include *.md)' + BranchReplaceRegex: "(^${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)$(DefaultBranch)(/.*)$" + BranchReplacementName: "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" Condition: succeeded() # If you want to run on failure for the link checker, set it to `Condition: succeededOrFailed()`. steps: @@ -27,7 +29,7 @@ steps: -rootUrl "file://${{ parameters.WorkingDirectory }}/${{ parameters.Directory }}" -recursive: ${{ parameters.Recursive }} -ignoreLinksFile ${{ parameters.IgnoreLinksFile }} - -branchReplaceRegex "(^${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)$(DefaultBranch)(/.*)$" - -branchReplacementName "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" + -branchReplaceRegex "${{ parameters.BranchReplaceRegex }}" + -branchReplacementName ${{ parameters.BranchReplacementName }} -devOpsLogging: $true - -checkLinkGuidance: ${{ parameters.CheckLinkGuidance }} \ No newline at end of file + -checkLinkGuidance: ${{ parameters.CheckLinkGuidance }} From e8592321a94eddd7fb05befa214382beeb80a95d Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 4 Mar 2021 15:54:03 -0800 Subject: [PATCH 22/24] 15 --- eng/common/pipelines/templates/steps/verify-links.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index 396ac7fb8412..7cf296d2f96e 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -11,12 +11,7 @@ parameters: Condition: succeeded() # If you want to run on failure for the link checker, set it to `Condition: succeededOrFailed()`. steps: - - pwsh: | - $setDefaultBranch = (git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' - Write-Host $setDefaultBranch - echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" - displayName: "Setup Default Branch" - condition: eq(variables['DefaultBranch'], '') + - template: /eng/common/pipelines/templates/steps/set-default-branch.yml - task: PowerShell@2 displayName: Link verification check condition: ${{ parameters.Condition }} @@ -32,4 +27,4 @@ steps: -branchReplaceRegex "${{ parameters.BranchReplaceRegex }}" -branchReplacementName ${{ parameters.BranchReplacementName }} -devOpsLogging: $true - -checkLinkGuidance: ${{ parameters.CheckLinkGuidance }} + -checkLinkGuidance: ${{ parameters.CheckLinkGuidance }} \ No newline at end of file From 59cb150ebd292bca426cc75941c990fbfc4109e3 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 4 Mar 2021 15:55:16 -0800 Subject: [PATCH 23/24] 16 --- .../pipelines/templates/steps/set-default-branch.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 eng/common/pipelines/templates/steps/set-default-branch.yml diff --git a/eng/common/pipelines/templates/steps/set-default-branch.yml b/eng/common/pipelines/templates/steps/set-default-branch.yml new file mode 100644 index 000000000000..7f50611bfa9a --- /dev/null +++ b/eng/common/pipelines/templates/steps/set-default-branch.yml @@ -0,0 +1,7 @@ +steps: +- pwsh: | + $setDefaultBranch = (git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' + Write-Host $setDefaultBranch + echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" + displayName: "Setup Default Branch" + condition: eq(variables['DefaultBranch'], '') \ No newline at end of file From 1459497847a7b84a9802ad9c9caf89029486bb01 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 4 Mar 2021 15:57:02 -0800 Subject: [PATCH 24/24] 17 --- .../pipelines/templates/steps/set-default-branch.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eng/common/pipelines/templates/steps/set-default-branch.yml b/eng/common/pipelines/templates/steps/set-default-branch.yml index 7f50611bfa9a..77e1d08a48d0 100644 --- a/eng/common/pipelines/templates/steps/set-default-branch.yml +++ b/eng/common/pipelines/templates/steps/set-default-branch.yml @@ -1,7 +1,7 @@ steps: - pwsh: | - $setDefaultBranch = (git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' - Write-Host $setDefaultBranch - echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" - displayName: "Setup Default Branch" - condition: eq(variables['DefaultBranch'], '') \ No newline at end of file + $setDefaultBranch = (git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' + Write-Host $setDefaultBranch + echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" + displayName: "Setup Default Branch" + condition: eq(variables['DefaultBranch'], '') \ No newline at end of file