@@ -18,11 +18,56 @@ resources:
1818
1919jobs :
2020
21+ # #############################
22+ - job : Get_Build_Options
23+ pool :
24+ vmImage : ' VS2017-Win2016'
25+
26+ steps :
27+ - checkout : self
28+ fetchDepth : 1
29+
30+ # get commit message
31+ - powershell : |
32+
33+ if($env:System_PullRequest_PullRequestId -ne '')
34+ {
35+ # PR build, get PR message
36+
37+ # need to get PR number from branch as the Azure Pipeline var can't be trusted
38+ if($env:Build_SourceBranch -match '(?<=(pull\/))\w*(?=(\/))')
39+ {
40+ $prNumber = $matches[0]
41+
42+ $prUrl = "https://api.github.com/repos/$env:Build_Repository_Name/pulls/$prNumber"
43+
44+ $commit = Invoke-RestMethod -Uri $prUrl -ContentType "application/json" -Method GET
45+
46+ $commitMessage = $commit.body
47+ }
48+ }
49+ else
50+ {
51+ # not a PR, get subject and commit message for commit
52+ $commitMessage = git log --format='%B' -1
53+ }
54+
55+ # need to flatten message by removing new lines
56+ $commitMessage = $commitMessage -replace "`r`n", " "
57+
58+ # set variable to foward to jobs
59+ echo "##vso[task.setvariable variable=COMMIT_MESSAGE;isOutput=true]$commitMessage"
60+ name: GetCommitMessage
61+ displayName: grab commit message
62+
2163# #############################
2264
2365# build MDP
2466- job : Build_MDP
25- condition : not( or( contains(variables['Build.SourceVersionMessage'], '***UPDATE_DEPENDENTS***'), eq(variables['UPDATE_DEPENDENTS'], 'true') ) )
67+ condition : not( or( contains(dependencies.Get_Build_Options.outputs['GetCommitMessage.COMMIT_MESSAGE'], '***UPDATE_DEPENDENTS***'), eq(variables['UPDATE_DEPENDENTS'], 'true') ) )
68+
69+ dependsOn :
70+ - Get_Build_Options
2671
2772 pool :
2873 vmImage : ' VS2017-Win2016'
@@ -143,10 +188,11 @@ jobs:
143188
144189# #############################
145190- job : Update_Dependents
146- condition : or( contains(variables['Build.SourceVersionMessage '], '***UPDATE_DEPENDENTS***'), eq(variables['UPDATE_DEPENDENTS'], 'true') )
191+ condition : or( contains(dependencies.Get_Build_Options.outputs['GetCommitMessage.COMMIT_MESSAGE '], '***UPDATE_DEPENDENTS***'), eq(variables['UPDATE_DEPENDENTS'], 'true') )
147192
148193 dependsOn :
149- - Build_MDP
194+ - Get_Build_Options
195+ - Build_MDP
150196
151197 pool :
152198 vmImage : ' VS2017-Win2016'
@@ -158,9 +204,6 @@ jobs:
158204
159205 - template : azure-pipelines-templates/install-nbgv-tool.yml@templates
160206
161- - script : nbgv cloud -a -c
162- displayName : Set build number
163-
164207 # update dependencies
165208 - task : PowerShell@2
166209 displayName : Update dependent class libs
0 commit comments