|
6 | 6 |
|
7 | 7 | package com.offbytwo.jenkins.model;
|
8 | 8 |
|
| 9 | +import com.fasterxml.jackson.annotation.JsonProperty; |
9 | 10 | import com.google.common.base.Predicate;
|
10 | 11 | import com.google.common.base.Strings;
|
11 | 12 | import com.google.common.collect.ImmutableMap;
|
@@ -124,6 +125,8 @@ public BuildResult getResult() {
|
124 | 125 | private String consoleOutputText;
|
125 | 126 | private String consoleOutputHtml;
|
126 | 127 | private BuildChangeSet changeSet;
|
| 128 | + @JsonProperty("changeSets") |
| 129 | + private List<BuildChangeSet> changeSets; |
127 | 130 | private String builtOn;
|
128 | 131 | private List<BuildChangeSetAuthor> culprits;
|
129 | 132 |
|
@@ -467,14 +470,56 @@ public ConsoleLog getConsoleOutputText(int bufferOffset) throws IOException {
|
467 | 470 | }
|
468 | 471 |
|
469 | 472 |
|
| 473 | + /** |
| 474 | + * Returns the change set of a build if available. |
| 475 | + * |
| 476 | + * If a build performs several scm checkouts (i.e. pipeline builds), the change set of the first |
| 477 | + * checkout is returned. To get the complete list of change sets for all checkouts, use |
| 478 | + * {@link #getChangeSets()} |
| 479 | + * |
| 480 | + * If no checkout is performed, null is returned. |
| 481 | + * |
| 482 | + * @return The change set of the build. |
| 483 | + * |
| 484 | + */ |
470 | 485 | public BuildChangeSet getChangeSet() {
|
471 |
| - return changeSet; |
| 486 | + BuildChangeSet result; |
| 487 | + if (changeSet != null) { |
| 488 | + result = changeSet; |
| 489 | + } else if (changeSets != null && !changeSets.isEmpty()) { |
| 490 | + result = changeSets.get(0); |
| 491 | + } else { |
| 492 | + result = null; |
| 493 | + } |
| 494 | + return result; |
472 | 495 | }
|
473 | 496 |
|
474 | 497 | public void setChangeSet(BuildChangeSet changeSet) {
|
475 | 498 | this.changeSet = changeSet;
|
476 | 499 | }
|
477 | 500 |
|
| 501 | + /** |
| 502 | + * Returns the complete list of change sets for all checkout the build has performed. If no |
| 503 | + * checkouts have been performed, returns null. |
| 504 | + * |
| 505 | + * @return The complete list of change sets of the build. |
| 506 | + */ |
| 507 | + public List<BuildChangeSet> getChangeSets() { |
| 508 | + List<BuildChangeSet> result; |
| 509 | + if (changeSets != null) { |
| 510 | + result = changeSets; |
| 511 | + } else if (changeSet != null) { |
| 512 | + result = Collections.singletonList(changeSet); |
| 513 | + } else { |
| 514 | + result = null; |
| 515 | + } |
| 516 | + return result; |
| 517 | + } |
| 518 | + |
| 519 | + public void setChangeSets(List<BuildChangeSet> changeSets) { |
| 520 | + this.changeSets = changeSets; |
| 521 | + } |
| 522 | + |
478 | 523 | public List<BuildChangeSetAuthor> getCulprits() {
|
479 | 524 | return culprits;
|
480 | 525 | }
|
@@ -528,6 +573,11 @@ public boolean equals(Object obj) {
|
528 | 573 | return false;
|
529 | 574 | } else if (!changeSet.equals(other.changeSet))
|
530 | 575 | return false;
|
| 576 | + if (changeSets == null) { |
| 577 | + if (other.changeSets != null) |
| 578 | + return false; |
| 579 | + } else if (!changeSets.equals(other.changeSets)) |
| 580 | + return false; |
531 | 581 | if (consoleOutputHtml == null) {
|
532 | 582 | if (other.consoleOutputHtml != null)
|
533 | 583 | return false;
|
@@ -583,6 +633,7 @@ public int hashCode() {
|
583 | 633 | result = prime * result + (building ? 1231 : 1237);
|
584 | 634 | result = prime * result + ((builtOn == null) ? 0 : builtOn.hashCode());
|
585 | 635 | result = prime * result + ((changeSet == null) ? 0 : changeSet.hashCode());
|
| 636 | + result = prime * result + ((changeSets == null) ? 0 : changeSets.hashCode()); |
586 | 637 | result = prime * result + ((consoleOutputHtml == null) ? 0 : consoleOutputHtml.hashCode());
|
587 | 638 | result = prime * result + ((consoleOutputText == null) ? 0 : consoleOutputText.hashCode());
|
588 | 639 | result = prime * result + ((culprits == null) ? 0 : culprits.hashCode());
|
|
0 commit comments