Skip to content

Commit 32a2d74

Browse files
Merge branch 'master' into migrate_to_junit5
2 parents f725ecf + e55c3e3 commit 32a2d74

File tree

7 files changed

+108
-4
lines changed

7 files changed

+108
-4
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Automatically approve and merge safe dependency updates
2+
on:
3+
- pull_request_target
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
jobs:
8+
auto-merge-safe-deps:
9+
uses: jenkins-infra/github-reusable-workflows/.github/workflows/auto-merge-safe-deps.yml@v1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Close BOM update PR if passing
2+
on:
3+
check_run:
4+
types:
5+
- completed
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
jobs:
10+
close-bom-if-passing:
11+
uses: jenkins-infra/github-reusable-workflows/.github/workflows/close-bom-if-passing.yml@v1

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
target
22
work
3-
*.iml
3+
*.iml
4+
.idea

.mvn/extensions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<extension>
33
<groupId>io.jenkins.tools.incrementals</groupId>
44
<artifactId>git-changelist-maven-extension</artifactId>
5-
<version>1.8</version>
5+
<version>1.13</version>
66
</extension>
77
</extensions>

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<parent>
2929
<groupId>org.jenkins-ci.plugins</groupId>
3030
<artifactId>plugin</artifactId>
31-
<version>5.26</version>
31+
<version>5.28</version>
3232
<relativePath />
3333
</parent>
3434
<groupId>org.jenkins-ci.plugins.workflow</groupId>
@@ -66,7 +66,7 @@
6666
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
6767
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
6868
<jenkins.baseline>2.479</jenkins.baseline>
69-
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
69+
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
7070
<no-test-jar>false</no-test-jar>
7171
<ban-junit4-imports.skip>false</ban-junit4-imports.skip>
7272
<hpi.strictBundledArtifacts>true</hpi.strictBundledArtifacts>

src/main/java/org/jenkinsci/plugins/workflow/steps/FlowInterruptedException.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import java.util.LinkedHashSet;
3737
import java.util.List;
3838
import java.util.Set;
39+
import java.util.stream.Collectors;
40+
3941
import edu.umd.cs.findbugs.annotations.CheckForNull;
4042
import edu.umd.cs.findbugs.annotations.NonNull;
4143
import jenkins.model.CauseOfInterruption;
@@ -109,6 +111,13 @@ private Object readResolve() {
109111
return this;
110112
}
111113

114+
@Override
115+
public String getMessage() {
116+
return causes.stream()
117+
.map(CauseOfInterruption::getShortDescription)
118+
.collect(Collectors.joining( ", " ));
119+
}
120+
112121
/**
113122
* If a build catches this exception, it should use this method to report it.
114123
*/
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* The MIT License
3+
*
4+
* Copyright 2025 Damian Szczepanik
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package org.jenkinsci.plugins.workflow.steps;
26+
27+
import static org.hamcrest.MatcherAssert.assertThat;
28+
import static org.hamcrest.Matchers.containsString;
29+
import static org.hamcrest.Matchers.equalTo;
30+
31+
import hudson.model.Result;
32+
import hudson.model.Run;
33+
import jenkins.model.CauseOfInterruption;
34+
import org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty;
35+
import org.junit.Assert;
36+
import org.junit.Test;
37+
import org.mockito.Mock;
38+
import org.mockito.Mockito;
39+
40+
/**
41+
* Tests some specific {@link FlowInterruptedException} APIs
42+
*/
43+
public class FlowInterruptedExceptionTest {
44+
45+
@Test
46+
public void getMessageReturnsCauses() {
47+
// given
48+
Result result = Result.ABORTED;
49+
CauseOfInterruption cause1 = new ExceptionCause(new IllegalStateException("something went wrong"));
50+
CauseOfInterruption cause2 = new CauseOfInterruption.UserInterruption("admin");
51+
CauseOfInterruption[] causes = {cause1, cause2};
52+
53+
// when
54+
FlowInterruptedException exception = new FlowInterruptedException(result, true, causes);
55+
56+
// then
57+
assertThat(exception.getMessage(), equalTo(cause1.getShortDescription() + ", " + cause2.getShortDescription()));
58+
}
59+
60+
@Test
61+
public void toStringContainsCauses() {
62+
// given
63+
Result result = Result.FAILURE;
64+
Run run = Mockito.mock(Run.class);
65+
Mockito.when(run.getDisplayName()).thenReturn("fracture.account");
66+
CauseOfInterruption cause = new DisableConcurrentBuildsJobProperty.CancelledCause(run);
67+
68+
// when
69+
FlowInterruptedException exception = new FlowInterruptedException(result, true, cause);
70+
71+
// then
72+
assertThat(exception.toString(), containsString(cause.getShortDescription()));
73+
}
74+
}

0 commit comments

Comments
 (0)