@@ -19,7 +19,7 @@ resources:
1919jobs :
2020
2121# #############################
22- - job : Get_Build_Options
22+ - job : Get_Build_Flags
2323 pool :
2424 vmImage : ' VS2017-Win2016'
2525
@@ -30,44 +30,48 @@ jobs:
3030 # get commit message
3131 - powershell : |
3232
33- if($env:System_PullRequest_PullRequestId -ne $null)
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
33+ # default to false
34+ $update = $false
4535
46- $commitMessage = $commit.body
47- }
36+ if($env:Build_Reason -eq 'PullRequest')
37+ {
38+ # PR build, nothing interesting in commit message
4839 }
4940 else
5041 {
51- # not a PR, get subject and commit message for commit
52- $commitMessage = git log --format='%B' -1
53- }
42+ # build is not from a PR
43+
44+ # get commit ID
45+ $commitId = git rev-parse HEAD
46+
47+ # get PR associate with commit
48+ $prUrl = "https://api.github.com/repos/nanoframework/metadata-processor/commits/$commitId/pulls"
49+ $commit = Invoke-RestMethod -Uri $prUrl -ContentType "application/json" -Headers @{"Accept"="application/vnd.github.groot-preview+json"} -Method GET
5450
55- # need to flatten message by removing new lines
56- $commitMessage = $commitMessage -replace "`r`n", " "
51+ if($commit -ne $null)
52+ {
53+ # there is a PR, check labels
54+ $updateDependents = $commit.labels | where {$_.Name -eq 'CI: Update Dependents'}
55+ if($updateDependents -ne $null)
56+ {
57+ $update = $true
58+ }
59+ }
60+ }
5761
5862 # set variable to foward to jobs
59- echo "##vso[task.setvariable variable=COMMIT_MESSAGE ;isOutput=true]$commitMessage "
63+ echo "##vso[task.setvariable variable=RUN_UPDATE_DEPENDENTS ;isOutput=true]$update "
6064 name: GetCommitMessage
61- displayName: grab commit message
65+ displayName: Check build labels
6266
6367# #############################
6468
6569# build MDP
6670- job : Build_MDP
67- condition : not( or( contains (dependencies.Get_Build_Options .outputs['GetCommitMessage.COMMIT_MESSAGE '], '***UPDATE_DEPENDENTS*** '), eq(variables['UPDATE_DEPENDENTS'], 'true') ) )
71+ condition : not( or( eq (dependencies.Get_Build_Flags .outputs['RUN_UPDATE_DEPENDENTS '], 'true '), eq(variables['UPDATE_DEPENDENTS'], 'true') ) )
6872
6973 dependsOn :
70- - Get_Build_Options
74+ - Get_Build_Flags
7175
7276 pool :
7377 vmImage : ' VS2017-Win2016'
@@ -91,17 +95,17 @@ jobs:
9195 displayName: Setup git identity
9296
9397 - task : NuGetToolInstaller@0
94- inputs :
95- versionSpec : ' 5.4.0'
9698 condition : not(variables['StartReleaseCandidate'])
9799 displayName : ' Install specific version of NuGet'
100+ inputs :
101+ versionSpec : ' 5.4.0'
98102
99103 - task : NuGetCommand@2
104+ displayName : NuGet restore
100105 inputs :
101106 restoreSolution : ' $(solution)'
102107 feedsToUse : config
103108 nugetConfigPath : ' NuGet.config'
104- displayName : NuGet restore
105109
106110 - task : VSBuild@1
107111 inputs :
@@ -111,48 +115,48 @@ jobs:
111115 configuration : ' $(buildConfiguration)'
112116
113117 - task : CopyFiles@1
118+ condition : succeeded()
119+ displayName : Collecting deployable artifacts
114120 inputs :
115121 sourceFolder : $(Build.SourcesDirectory)
116122 Contents : |
117123 **\bin\Release\nanoFramework.Tools.MetaDataProcessor.exe
118124 TargetFolder : ' $(Build.ArtifactStagingDirectory)'
119125 flattenFolders : true
120- condition : succeeded()
121- displayName : Collecting deployable artifacts
122126
123127 # update could build number (only possible if this is not a PR from a fork)
124128 - task : PowerShell@2
129+ condition : and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
130+ displayName : Update cloud build number
125131 inputs :
126132 targetType : ' inline'
127133 script : Write-Host "$("##vso[build.updatebuildnumber]")$env:NBGV_NuGetPackageVersion"
128- condition : and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
129- displayName : Update cloud build number
130134
131135 - task : NuGetCommand@2
136+ condition : succeeded()
137+ displayName : Pack NuGet witj MDP tool
132138 inputs :
133139 command : ' custom'
134- arguments : ' pack MetadataProcessor.Core\package.nuspec -Version $(NBGV_NuGetPackageVersion)'
135- condition : succeeded()
136- displayName : Pack NuGet for MDP tool
140+ arguments : ' pack MetadataProcessor.Core\package.nuspec -Version $(NBGV_NuGetPackageVersion) -properties commit="$(Build.SourceVersion)"'
137141
138142 - task : CopyFiles@1
143+ condition : succeeded()
144+ displayName : Collecting NuGet package artifact
139145 inputs :
140146 sourceFolder : $(Build.SourcesDirectory)
141147 Contents : |
142148 **\nanoFramework*.nupkg
143149 TargetFolder : ' $(Build.ArtifactStagingDirectory)'
144150 flattenFolders : true
145- condition : succeeded()
146- displayName : Collecting NuGet package artifact
147151
148152 # publish artifacts (only possible if this is not a PR originated on a fork)
149153 - task : PublishBuildArtifacts@1
154+ condition : and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
155+ displayName : Publish deployables artifacts
150156 inputs :
151157 PathtoPublish : ' $(Build.ArtifactStagingDirectory)'
152158 ArtifactName : deployables
153159 ArtifactType : Container
154- condition : and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
155- displayName : Publish deployables artifacts
156160
157161 # push NuGet packages to Azure Artifacts feed (always happens except on PR builds)
158162 - task : NuGetCommand@2
@@ -188,10 +192,10 @@ jobs:
188192
189193# #############################
190194- job : Update_Dependents
191- condition : or( contains (dependencies.Get_Build_Options .outputs['GetCommitMessage.COMMIT_MESSAGE '], '***UPDATE_DEPENDENTS*** '), eq(variables['UPDATE_DEPENDENTS'], 'true') )
195+ condition : or( eq (dependencies.Get_Build_Flags .outputs['RUN_UPDATE_DEPENDENTS '], 'true '), eq(variables['UPDATE_DEPENDENTS'], 'true') )
192196
193197 dependsOn :
194- - Get_Build_Options
198+ - Get_Build_Flags
195199 - Build_MDP
196200
197201 pool :
0 commit comments