Commit ec4350c
committed
Handle NOT_BUILT and ABORTED as other results
Use case
--------
My use case is a post build script which does not need to fully
complete, that does get cancelled while waiting and causes the
triggering build to fail as a result I need the build step result to be
passed through the BlockingBehavior so that I can set it to never block
and thus be considered a SUCCESS even when NOT_BUILT or ABORTED.
See: https://phabricator.wikimedia.org/T352319
Solution
--------
When a triggered job is aborted (InterruptedException), the build step
was throwing an AbortException which marks the parent job has having
been aborted. This change catches it as an ABORTED result and passes it
through the BlockingBehavior to determine the build step outcome.
Jenkins Result defines ordinal ranking 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.
BREAKING CHANGE: since ABORTED has a worse ordinal than FAILURE, the
aborted build step causes the build to now be marked FAILURE.
This is reflected in testCancelsDownstreamBuildWhenInterrupted() test
which now becomes a SUCCESS (since the test blocking behavior is to
never block).
When a job is cancelled from the build queue (CancellationException),
catch it, set the result to NOT_BUILD and pass it through the
BlockingBehavior. This lets one to configure the build step to never
fail or mark the build unstable when previously the exception would
bubble up and call the build to fail.
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 f60b7e3 commit ec4350c
File tree
2 files changed
+80
-41
lines changed- src
- main/java/hudson/plugins/parameterizedtrigger
- test/java/hudson/plugins/parameterizedtrigger/test
2 files changed
+80
-41
lines changedLines changed: 42 additions & 39 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 | | - | |
174 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
175 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
176 | 167 | | |
177 | | - | |
178 | | - | |
179 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
180 | 171 | | |
181 | 172 | | |
182 | | - | |
| 173 | + | |
183 | 174 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
188 | 180 | | |
189 | 181 | | |
190 | 182 | | |
191 | 183 | | |
192 | 184 | | |
193 | 185 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
203 | 193 | | |
204 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
205 | 208 | | |
206 | 209 | | |
207 | 210 | | |
| |||
Lines changed: 38 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
251 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 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 | + | |
252 | 288 | | |
253 | 289 | | |
254 | 290 | | |
| |||
0 commit comments