@@ -19,7 +19,7 @@ resources:
19
19
jobs :
20
20
21
21
# #############################
22
- - job : Get_Build_Options
22
+ - job : Get_Build_Flags
23
23
pool :
24
24
vmImage : ' VS2017-Win2016'
25
25
@@ -30,44 +30,48 @@ jobs:
30
30
# get commit message
31
31
- powershell : |
32
32
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
45
35
46
- $commitMessage = $commit.body
47
- }
36
+ if($env:Build_Reason -eq 'PullRequest')
37
+ {
38
+ # PR build, nothing interesting in commit message
48
39
}
49
40
else
50
41
{
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
54
50
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
+ }
57
61
58
62
# 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 "
60
64
name: GetCommitMessage
61
- displayName: grab commit message
65
+ displayName: Check build labels
62
66
63
67
# #############################
64
68
65
69
# build MDP
66
70
- 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') ) )
68
72
69
73
dependsOn :
70
- - Get_Build_Options
74
+ - Get_Build_Flags
71
75
72
76
pool :
73
77
vmImage : ' VS2017-Win2016'
@@ -91,17 +95,17 @@ jobs:
91
95
displayName: Setup git identity
92
96
93
97
- task : NuGetToolInstaller@0
94
- inputs :
95
- versionSpec : ' 5.4.0'
96
98
condition : not(variables['StartReleaseCandidate'])
97
99
displayName : ' Install specific version of NuGet'
100
+ inputs :
101
+ versionSpec : ' 5.4.0'
98
102
99
103
- task : NuGetCommand@2
104
+ displayName : NuGet restore
100
105
inputs :
101
106
restoreSolution : ' $(solution)'
102
107
feedsToUse : config
103
108
nugetConfigPath : ' NuGet.config'
104
- displayName : NuGet restore
105
109
106
110
- task : VSBuild@1
107
111
inputs :
@@ -111,48 +115,48 @@ jobs:
111
115
configuration : ' $(buildConfiguration)'
112
116
113
117
- task : CopyFiles@1
118
+ condition : succeeded()
119
+ displayName : Collecting deployable artifacts
114
120
inputs :
115
121
sourceFolder : $(Build.SourcesDirectory)
116
122
Contents : |
117
123
**\bin\Release\nanoFramework.Tools.MetaDataProcessor.exe
118
124
TargetFolder : ' $(Build.ArtifactStagingDirectory)'
119
125
flattenFolders : true
120
- condition : succeeded()
121
- displayName : Collecting deployable artifacts
122
126
123
127
# update could build number (only possible if this is not a PR from a fork)
124
128
- task : PowerShell@2
129
+ condition : and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
130
+ displayName : Update cloud build number
125
131
inputs :
126
132
targetType : ' inline'
127
133
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
130
134
131
135
- task : NuGetCommand@2
136
+ condition : succeeded()
137
+ displayName : Pack NuGet witj MDP tool
132
138
inputs :
133
139
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)"'
137
141
138
142
- task : CopyFiles@1
143
+ condition : succeeded()
144
+ displayName : Collecting NuGet package artifact
139
145
inputs :
140
146
sourceFolder : $(Build.SourcesDirectory)
141
147
Contents : |
142
148
**\nanoFramework*.nupkg
143
149
TargetFolder : ' $(Build.ArtifactStagingDirectory)'
144
150
flattenFolders : true
145
- condition : succeeded()
146
- displayName : Collecting NuGet package artifact
147
151
148
152
# publish artifacts (only possible if this is not a PR originated on a fork)
149
153
- task : PublishBuildArtifacts@1
154
+ condition : and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
155
+ displayName : Publish deployables artifacts
150
156
inputs :
151
157
PathtoPublish : ' $(Build.ArtifactStagingDirectory)'
152
158
ArtifactName : deployables
153
159
ArtifactType : Container
154
- condition : and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
155
- displayName : Publish deployables artifacts
156
160
157
161
# push NuGet packages to Azure Artifacts feed (always happens except on PR builds)
158
162
- task : NuGetCommand@2
@@ -188,10 +192,10 @@ jobs:
188
192
189
193
# #############################
190
194
- 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') )
192
196
193
197
dependsOn :
194
- - Get_Build_Options
198
+ - Get_Build_Flags
195
199
- Build_MDP
196
200
197
201
pool :
0 commit comments