Skip to content

Commit

Permalink
Disable submodules where not needed and add pipeline message for PR b…
Browse files Browse the repository at this point in the history
…uilds (#1967)

* Print out some ngbv variables to try to get the preview version

* Add PR branch string to pipeline version, wrap printouts in quotes

* Fix conditionals for PR Branch parameter

* Fix PRBranch variable name

* Experimenting with not checking out submodules for some jobs

* Fix Submodules boolean type

* explicitly disable submodules

* Change to environment vars

* Print json data from nbgv

* Set pipeline version to CloudBuildNumber

* Remove PipelineType for win32docs

* Fix pr branch name

* Print jsonString

* More changes to pipeline message

* Fix quotes powershell script

* Use version number that includes prerelease for PR pipeline runs

* Fix up task variable setting
  • Loading branch information
getrou authored Aug 23, 2024
1 parent 185c3ef commit e012b29
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
4 changes: 1 addition & 3 deletions AzurePipelinesTemplates/win32docs-onebranch.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
parameters:
- name: "PipelineType"
type: string
default: "PullRequest"
- name: "RepoDirectory"
type: string
default: "s"
Expand All @@ -28,6 +25,7 @@ stages:
- template: win32metadata-checkout.yml
parameters:
RepoDirectory: ${{ parameters.RepoDirectory }}
Submodules: true
- task: UseDotNet@2
displayName: ⚙ Install .NET SDK
inputs:
Expand Down
8 changes: 7 additions & 1 deletion AzurePipelinesTemplates/win32metadata-checkout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ parameters:
- name: "RepoDirectory"
type: string
default: "win32metadata"
- name: "Submodules"
type: boolean
default: false

steps:
- script: git config --global core.longpaths true
- checkout: win32metadata
path: s/${{ parameters.RepoDirectory }}
lfs: false
displayName: Checkout win32metadata from github
submodules: recursive
${{ if parameters.Submodules }}:
submodules: recursive
${{ if not(parameters.Submodules) }}:
submodules: false
45 changes: 37 additions & 8 deletions AzurePipelinesTemplates/win32metadata-onebranch.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
parameters:
- name: "PipelineType"
type: string
default: "PullRequest"
- name: "RepoDirectory"
type: string
default: "s" # Shortened repo directory name to keep paths under 260 characters. OneBranch issue where longpath setting doesn't get pushed down to submodules.
- name: OfficialBuild
type: boolean
default: false
- name: 'PRBranch' # Used to name pipeline runs for PR builds
displayName: 'PR branch'
type: string
default: ''

stages:
- stage: scrape
Expand All @@ -21,8 +22,10 @@ stages:
generateMetadataArgs: '-scrapeConstants'
x64:
arch: 'x64'
generateMetadataArgs: ''
arm64:
arch: 'arm64'
generateMetadataArgs: ''
displayName: "Scrape headers"
timeoutInMinutes: 60
variables:
Expand Down Expand Up @@ -63,15 +66,41 @@ stages:
script: |
$jsonString = nbgv get-version -f json
$nbgvData = $jsonString | ConvertFrom-Json
Write-Host $jsonString
$commitId = $nbgvData.GitCommitId
$version = $nbgvData.CloudBuildNumber
Write-Host "##vso[task.setvariable variable=CommitId;]$commitId"
Write-Host "##vso[task.setvariable variable=Version;]$version"
$commitMessage = git log --format=%B -n 1 $commitId
$pipeline_message = '${{ parameters.PRBranch }}' + ' • ' + $commitMessage
$pipeline_message = $pipeline_message -replace '["/:<>\\|?@*]','_'
if ($pipeline_message.Length -gt 200) {
$pipeline_message = $pipeline_message.Substring(0, 200) + '...'
}
Write-Host "##vso[task.setvariable variable=PipelineMessage;]$pipeline_message"
Write-Host "Setting Version to $version"
Write-Host "Setting CommitId to $commitId"
Write-Host "Setting PipelineMessage to $pipeline_message"
# Set the pipeline build number
- task: onebranch.pipeline.version@1
condition: eq(variables.arch, 'x64')
inputs:
system: 'Custom'
customVersion: '$(GitBuildVersionSimple)'
- ${{ if eq(parameters.PRBranch, '') }}:
- task: onebranch.pipeline.version@1
condition: eq(variables.arch, 'x64')
inputs:
system: 'Custom'
customVersion: '$(Version)'

# Add the PR Branch to the build version for clarity if this is a PR build
# The Pipeline Version is used as part of the Github release in the Offical builds,
# so we don't set it in Offical pipeline runs
- ${{ if ne(parameters.PRBranch, '') }}:
- task: onebranch.pipeline.version@1
condition: eq(variables.arch, 'x64')
inputs:
system: 'Custom'
customVersion: '$(Version) • $(PipelineMessage)'

- task: PowerShell@2
displayName: GenerateMetadataSource.ps1
Expand Down

0 comments on commit e012b29

Please sign in to comment.