Skip to content

Commit e1b44c8

Browse files
Merge branch 'release/1.x' into patch-1
2 parents ec31d60 + 4699527 commit e1b44c8

9 files changed

Lines changed: 141 additions & 140 deletions

File tree

.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.10</version>
66
</extension>
77
</extensions>

pom.xml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
<parent>
44
<groupId>org.jenkins-ci.plugins</groupId>
55
<artifactId>plugin</artifactId>
6-
<version>4.88</version>
6+
<version>5.24</version>
77
<relativePath />
88
</parent>
99
<packaging>hpi</packaging>
1010
<properties>
1111
<revision>1</revision>
1212
<changelist>999999-SNAPSHOT</changelist>
1313
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
14-
<jenkins.baseline>2.440</jenkins.baseline>
14+
<jenkins.baseline>2.479</jenkins.baseline>
1515
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
16+
<ban-junit4-imports.skip>false</ban-junit4-imports.skip>
1617
<hpi.compatibleSinceVersion>1.9</hpi.compatibleSinceVersion>
1718
</properties>
1819
<artifactId>stashNotifier</artifactId>
@@ -82,7 +83,7 @@
8283
<dependency>
8384
<groupId>io.jenkins.tools.bom</groupId>
8485
<artifactId>bom-${jenkins.baseline}.x</artifactId>
85-
<version>3387.v0f2773fa_3200</version>
86+
<version>5054.v620b_5d2b_d5e6</version>
8687
<scope>import</scope>
8788
<type>pom</type>
8889
</dependency>
@@ -113,11 +114,6 @@
113114
<artifactId>plain-credentials</artifactId>
114115
<type>jar</type>
115116
</dependency>
116-
<dependency>
117-
<groupId>junit</groupId>
118-
<artifactId>junit</artifactId>
119-
<scope>test</scope>
120-
</dependency>
121117
<dependency>
122118
<groupId>org.mockito</groupId>
123119
<artifactId>mockito-core</artifactId>
@@ -145,3 +141,4 @@
145141
</dependency>
146142
</dependencies>
147143
</project>
144+

src/main/java/org/jenkinsci/plugins/stashNotifier/StashNotifier.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import edu.umd.cs.findbugs.annotations.NonNull;
2727
import hudson.Extension;
2828
import hudson.FilePath;
29+
import hudson.EnvVars;
2930
import hudson.Launcher;
3031
import hudson.ProxyConfiguration;
3132
import hudson.model.*;
@@ -361,26 +362,29 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
361362
return disableInprogressNotification || processJenkinsEvent(build, null, listener, StashBuildState.INPROGRESS);
362363
}
363364

365+
@Override
366+
public boolean requiresWorkspace() {
367+
return false;
368+
}
369+
364370
@Override
365371
public boolean perform(
366372
AbstractBuild<?, ?> build,
367373
Launcher launcher,
368374
BuildListener listener) {
369-
return perform(build, null, listener, disableInprogressNotification);
375+
return perform(build, listener, disableInprogressNotification);
370376
}
371377

372378
@Override
373379
public void perform(@NonNull Run<?, ?> run,
374-
@NonNull FilePath workspace,
375-
@NonNull Launcher launcher,
380+
@NonNull EnvVars env,
376381
@NonNull TaskListener listener) {
377-
if (!perform(run, workspace, listener, false)) {
382+
if (!perform(run, listener, false)) {
378383
run.setResult(Result.FAILURE);
379384
}
380385
}
381386

382387
private boolean perform(Run<?, ?> run,
383-
FilePath workspace,
384388
TaskListener listener,
385389
boolean disableInProgress) {
386390
StashBuildState state;

src/test/java/org/jenkinsci/plugins/stashNotifier/BuildStatusUriFactoryTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
package org.jenkinsci.plugins.stashNotifier;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
import java.net.URI;
66

77
import static org.hamcrest.MatcherAssert.assertThat;
88
import static org.hamcrest.core.IsEqual.equalTo;
99

10-
public class BuildStatusUriFactoryTest {
10+
class BuildStatusUriFactoryTest {
1111

1212
@Test
13-
public void shouldHandleTrailingSlash() {
13+
void shouldHandleTrailingSlash() {
1414
String baseUri = "http://localhost:12345/";
1515
URI expected = URI.create("http://localhost:12345/rest/build-status/1.0/commits/25a4b3c9b494fc7ac65b80e3b0ecce63f235f20d");
1616
URI actual = BuildStatusUriFactory.create(baseUri, "25a4b3c9b494fc7ac65b80e3b0ecce63f235f20d");
1717
assertThat(actual, equalTo(expected));
1818
}
1919

2020
@Test
21-
public void shouldHandleNoTrailingSlash() {
21+
void shouldHandleNoTrailingSlash() {
2222
String baseUri = "http://localhost:12345";
2323
URI expected = URI.create("http://localhost:12345/rest/build-status/1.0/commits/25a4b3c9b494fc7ac65b80e3b0ecce63f235f20d");
2424
URI actual = BuildStatusUriFactory.create(baseUri, "25a4b3c9b494fc7ac65b80e3b0ecce63f235f20d");
2525
assertThat(actual, equalTo(expected));
2626
}
2727

2828
@Test
29-
public void shouldHandleBasePathTrailingSlash() {
29+
void shouldHandleBasePathTrailingSlash() {
3030
String baseUri = "http://localhost:12345/some-path/";
3131
URI expected = URI.create("http://localhost:12345/some-path/rest/build-status/1.0/commits/25a4b3c9b494fc7ac65b80e3b0ecce63f235f20d");
3232
URI actual = BuildStatusUriFactory.create(baseUri, "25a4b3c9b494fc7ac65b80e3b0ecce63f235f20d");
3333
assertThat(actual, equalTo(expected));
3434
}
3535

3636
@Test
37-
public void shouldHandleBasePathNoTrailingSlash() {
37+
void shouldHandleBasePathNoTrailingSlash() {
3838
String baseUri = "http://localhost:12345/some-path";
3939
URI expected = URI.create("http://localhost:12345/some-path/rest/build-status/1.0/commits/25a4b3c9b494fc7ac65b80e3b0ecce63f235f20d");
4040
URI actual = BuildStatusUriFactory.create(baseUri, "25a4b3c9b494fc7ac65b80e3b0ecce63f235f20d");

src/test/java/org/jenkinsci/plugins/stashNotifier/ConfigAsCodeTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import io.jenkins.plugins.casc.ConfiguratorRegistry;
55
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
66
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
7+
import io.jenkins.plugins.casc.misc.junit.jupiter.WithJenkinsConfiguredWithCode;
78
import io.jenkins.plugins.casc.model.CNode;
8-
import org.junit.Rule;
9-
import org.junit.Test;
9+
import org.junit.jupiter.api.Test;
1010

1111
import static io.jenkins.plugins.casc.misc.Util.getUnclassifiedRoot;
1212
import static io.jenkins.plugins.casc.misc.Util.toStringFromYamlFile;
@@ -15,12 +15,12 @@
1515
import static org.hamcrest.Matchers.equalTo;
1616
import static org.hamcrest.core.Is.is;
1717

18-
public class ConfigAsCodeTest {
19-
@Rule public JenkinsConfiguredWithCodeRule rule = new JenkinsConfiguredWithCodeRule();
18+
@WithJenkinsConfiguredWithCode
19+
class ConfigAsCodeTest {
2020

2121
@Test
2222
@ConfiguredWithCode("configuration-as-code.yml")
23-
public void should_support_jcasc_from_yaml() {
23+
void should_support_jcasc_from_yaml(JenkinsConfiguredWithCodeRule rule) {
2424
StashNotifier.DescriptorImpl stashNotifierConfig = rule.jenkins.getDescriptorByType(StashNotifier.DescriptorImpl.class);
2525

2626
assertThat(stashNotifierConfig.isConsiderUnstableAsSuccess(), equalTo(true));
@@ -34,7 +34,7 @@ public void should_support_jcasc_from_yaml() {
3434

3535
@Test
3636
@ConfiguredWithCode("configuration-as-code.yml")
37-
public void should_support_jcasc_to_yaml() throws Exception {
37+
void should_support_jcasc_to_yaml(JenkinsConfiguredWithCodeRule rule) throws Exception {
3838
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
3939
ConfigurationContext context = new ConfigurationContext(registry);
4040
CNode yourAttribute = getUnclassifiedRoot(context).get("notifyBitbucket");

src/test/java/org/jenkinsci/plugins/stashNotifier/DefaultApacheHttpNotifierTest.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import hudson.util.Secret;
1515
import jenkins.model.Jenkins;
1616
import net.sf.json.JSONObject;
17-
import org.acegisecurity.Authentication;
1817
import org.apache.http.StatusLine;
1918
import org.apache.http.client.config.CookieSpecs;
2019
import org.apache.http.client.config.RequestConfig;
@@ -25,10 +24,10 @@
2524
import org.apache.http.impl.client.CloseableHttpClient;
2625
import org.apache.http.impl.client.HttpClientBuilder;
2726
import org.jenkinsci.plugins.tokenmacro.TokenMacro;
28-
import org.junit.AfterClass;
29-
import org.junit.Before;
30-
import org.junit.BeforeClass;
31-
import org.junit.Test;
27+
import org.junit.jupiter.api.AfterAll;
28+
import org.junit.jupiter.api.BeforeAll;
29+
import org.junit.jupiter.api.BeforeEach;
30+
import org.junit.jupiter.api.Test;
3231

3332
import java.io.File;
3433
import java.io.PrintStream;
@@ -39,6 +38,7 @@
3938

4039
import org.mockito.ArgumentCaptor;
4140
import org.mockito.MockedStatic;
41+
import org.springframework.security.core.Authentication;
4242

4343
import static org.hamcrest.MatcherAssert.assertThat;
4444
import static org.hamcrest.Matchers.is;
@@ -51,9 +51,9 @@
5151
import static org.mockito.Mockito.verify;
5252
import static org.mockito.Mockito.when;
5353

54-
public class DefaultApacheHttpNotifierTest {
54+
class DefaultApacheHttpNotifierTest {
5555

56-
final static String sha1 = "1234567890123456789012345678901234567890";
56+
private static final String SHA_1 = "1234567890123456789012345678901234567890";
5757
private static CloseableHttpClient client;
5858
private static MockedStatic<Jenkins> mockedJenkins;
5959
private static MockedStatic<CredentialsProvider> mockedCredentialsProvider;
@@ -65,8 +65,8 @@ public class DefaultApacheHttpNotifierTest {
6565
private static BuildListener buildListener;
6666
private HttpClientBuilder httpClientBuilder;
6767

68-
@BeforeClass
69-
public static void setUp() throws Exception {
68+
@BeforeAll
69+
static void beforeAll() throws Exception {
7070
mockedSecret = mockStatic(Secret.class);
7171
mockedJenkins = mockStatic(Jenkins.class);
7272
mockedStaticHttpClientBuilder = mockStatic(HttpClientBuilder.class);
@@ -100,13 +100,13 @@ public static void setUp() throws Exception {
100100
when(jenkins.getRootUrl()).thenReturn("http://localhost/");
101101
when(build.getEnvironment(buildListener)).thenReturn(environment);
102102
when(action.getLastBuiltRevision()).thenReturn(revision);
103-
when(revision.getSha1String()).thenReturn(sha1);
103+
when(revision.getSha1String()).thenReturn(SHA_1);
104104
doReturn(project).when(build).getProject();
105105
doReturn(project).when(run).getParent();
106106
when(build.getFullDisplayName()).thenReturn("foo");
107107
when(build.getUrl()).thenReturn("foo");
108108
when(build.getActions(BuildData.class)).thenReturn(actions);
109-
when(environment.expand(anyString())).thenReturn(sha1);
109+
when(environment.expand(anyString())).thenReturn(SHA_1);
110110
when(buildListener.getLogger()).thenReturn(logger);
111111
when(Secret.fromString("tiger")).thenReturn(secret);
112112
when(Secret.toString(secret)).thenReturn("tiger");
@@ -118,25 +118,25 @@ public static void setUp() throws Exception {
118118
when(lastBuild.getMarked()).thenReturn(revision);
119119

120120
when(TokenMacro.expandAll(build, buildListener, "test-project")).thenReturn("prepend-key");
121-
when(CredentialsProvider.lookupCredentials(
121+
when(CredentialsProvider.lookupCredentialsInItemGroup(
122122
any(),
123123
any(ItemGroup.class),
124124
any(Authentication.class),
125125
anyList()
126126
)).thenReturn(new ArrayList<>());
127127
}
128128

129-
@AfterClass
130-
public static void close() {
129+
@AfterAll
130+
static void afterAll() {
131131
mockedJenkins.close();
132132
mockedCredentialsProvider.close();
133133
mockedSecret.close();
134134
mockedStaticHttpClientBuilder.close();
135135
mockedTokenMacro.close();
136136
}
137137

138-
@Before
139-
public void before() {
138+
@BeforeEach
139+
void beforeEach() {
140140
httpClientBuilder = mock(HttpClientBuilder.class);
141141
when(HttpClientBuilder.create()).thenReturn(httpClientBuilder);
142142
when(httpClientBuilder.build()).thenReturn(client);
@@ -156,19 +156,19 @@ private NotificationResult notifyStash(int statusCode) throws Exception {
156156
}
157157

158158
@Test
159-
public void notifyStash_success() throws Exception {
159+
void notifyStash_success() throws Exception {
160160
NotificationResult notificationResult = notifyStash(204);
161161
assertThat(notificationResult.indicatesSuccess, is(true));
162162
}
163163

164164
@Test
165-
public void notifyStash_fail() throws Exception {
165+
void notifyStash_fail() throws Exception {
166166
NotificationResult notificationResult = notifyStash(400);
167167
assertThat(notificationResult.indicatesSuccess, is(false));
168168
}
169169

170170
@Test
171-
public void notifyStashUsesRequestParameters() throws Exception {
171+
void notifyStashUsesRequestParameters() throws Exception {
172172
notifyStash(204);
173173

174174
final ArgumentCaptor<RequestConfig> captor = ArgumentCaptor.forClass(RequestConfig.class);

0 commit comments

Comments
 (0)