Skip to content

Commit 80c9608

Browse files
authored
#234: Do not require a workspace to notify Bitbucket (#425)
2 parents 0267e41 + 89b23bc commit 80c9608

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

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/StashNotifierTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ private StashNotifier buildStashNotifier(String stashBaseUrl,
111111
private static BuildListener buildListener;
112112
private static AbstractBuild<?, ?> build;
113113
private static Run<?, ?> run;
114-
private static FilePath workspace;
115114

116115
@BeforeClass
117116
public static void setUp() throws Exception {
@@ -131,7 +130,6 @@ public static void setUp() throws Exception {
131130
when(file.getPath()).thenReturn("/tmp/fake/path");
132131
FilePath filePath = new FilePath(file);
133132
when(project.getSomeWorkspace()).thenReturn(filePath);
134-
workspace = project.getSomeWorkspace();
135133
EnvVars environment = mock(EnvVars.class);
136134
PrintStream logger = System.out;
137135
Secret secret = mock(Secret.class);
@@ -295,7 +293,7 @@ private void test_perform_simplebuildstep(Result result,
295293
Launcher launcher = test_perform(result, logger, notificationResult, hashes);
296294

297295
//when
298-
sn.perform(build, workspace, launcher, buildListener);
296+
sn.perform(build, launcher, buildListener);
299297

300298
//then
301299
assertThat(build.getResult(), is(result));
@@ -483,7 +481,7 @@ public void test_perform_simple_build_step_empty_hash() {
483481
doReturn(new ArrayList<String>()).when(sn).lookupCommitSha1s(eq(build), eq(null), eq(buildListener));
484482

485483
//when
486-
sn.perform(build, workspace, mock(Launcher.class), buildListener);
484+
sn.perform(build, mock(Launcher.class), buildListener);
487485

488486
//then
489487
verify(sn, never()).notifyStash(

0 commit comments

Comments
 (0)