Commit a455d7e
committed
Handle NOT_BUILT and ABORTED as other results
Use case
--------
My use case is a post build script trigger a job which does not need to
fully complete. The step can be cancelled while waiting (or building)
and that caused the triggering build to be marked as a failure.
To fix that, I need the plugin to pass the result of the build step
through BlockingBehaviour which lets one define how to behave when the
triggered build got NOT_BUILT or ABORTED, in my case I need it to never
block.
See: https://phabricator.wikimedia.org/T352319
Solution
--------
There are multiple reasons for a job to not fully complete:
- it is interrupted, an InterruptedException is thrown, this is still
rethrow and Jenkins will make the build as ABORTED.
- it can be cancelled from the build queue raising a
CancellationException. This previously raised an AbortException which
marks the build as a failure, I have changed it to a NOT_BUILT result
which can be process as other results (notably never block on it).
The Jenkins Result class ranks the results as:
- SUCCESS
- UNSTABLE
- FAILURE
- NOT_BUILT
- ABORTED.
The NOT_BUILT and ABORTED results are thus worse than a FAILURE and
would be matched as such in BlockingBehavior mapBuildStepResult() and
mapBuildResult() which uses isWorseOrEqualTo() for comparison.
Add a test testCancelledFromBuildQueue() to cover the
CancellationException() is caught and it results in a SUCCESS (since the
test blocking behavior is to never block).
ResultConditionTest covers the BlockingBehavior is able to map NOT_BUILD
and ABORTED since it has two tests explicitly cancelling and
interrupting jobs.
Examples
--------
When a build is aborted, by aborting it:
Waiting for the completion of downstream-project
downstream-project #7 started.
downstream-project #7 completed. Result was ABORTED
Build step 'Trigger/call builds on other projects' marked build as failure
Finished: FAILURE
When it is waiting in the build queue and cancelled:
Waiting for the completion of downstream-project
Not built: downstream-project has been cancelled while waiting in the queue.
Build step 'Trigger/call builds on other projects' marked build as failure
Finished: FAILURE1 parent 458bf27 commit a455d7e
File tree
2 files changed
+67
-30
lines changed- src
- main/java/hudson/plugins/parameterizedtrigger
- test/java/hudson/plugins/parameterizedtrigger/test
2 files changed
+67
-30
lines changedLines changed: 34 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 153 | + | |
161 | 154 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
174 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
175 | 167 | | |
176 | 168 | | |
177 | 169 | | |
178 | 170 | | |
179 | 171 | | |
180 | 172 | | |
181 | | - | |
| 173 | + | |
182 | 174 | | |
183 | 175 | | |
184 | 176 | | |
185 | 177 | | |
| 178 | + | |
186 | 179 | | |
187 | 180 | | |
188 | 181 | | |
189 | 182 | | |
190 | 183 | | |
191 | 184 | | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
200 | 191 | | |
201 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
202 | 206 | | |
203 | 207 | | |
204 | 208 | | |
| |||
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
256 | 289 | | |
257 | 290 | | |
258 | 291 | | |
| |||
0 commit comments