Skip to content

Commit 5c1adcf

Browse files
author
jan
committed
Postbuild commands should not be run when the build failed #1699
1 parent 2928d93 commit 5c1adcf

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/InternalBuildRunner.java

+28-25
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ public boolean invokeBuild(int kind, String targetName, IAutoBuildConfigurationD
135135
epm.deferDeDuplication();
136136
int sequenceID = -1;
137137
boolean lastSequenceID = true;
138+
myHasBuildError = false;
138139

139140
// Run preBuildStep if existing
140141
LinkedHashMap<String,String> preBuildSteps = autoData.getPrebuildSteps();
@@ -147,13 +148,14 @@ public boolean invokeBuild(int kind, String targetName, IAutoBuildConfigurationD
147148
}
148149
buildRunnerHelper.toConsole(command);
149150
if (launchCommand(command, autoData, monitor, buildRunnerHelper) != 0) {
151+
myHasBuildError = true;
150152
if (autoData.stopOnFirstBuildError()) {
151153
return false;
152154
}
153155
}
154156
}
155157

156-
myHasBuildError = false;
158+
157159
do {
158160
sequenceID++;
159161
lastSequenceID = true;
@@ -218,35 +220,36 @@ public boolean invokeBuild(int kind, String targetName, IAutoBuildConfigurationD
218220
lastSequenceID = true;
219221
}
220222
} while (!(lastSequenceID || myHasBuildError));
221-
// Run postBuildStep if existing
222223

223-
LinkedHashMap<String,String> postBuildSteps = autoData.getPostbuildSteps();
224-
for (Entry<String, String> step:postBuildSteps.entrySet()) {
225-
String announcement = step.getKey();
226-
String command = step.getValue();
224+
// Run postBuildStep if existing and no error
225+
if (!myHasBuildError) {
226+
LinkedHashMap<String, String> postBuildSteps = autoData.getPostbuildSteps();
227+
for (Entry<String, String> step : postBuildSteps.entrySet()) {
228+
String announcement = step.getKey();
229+
String command = step.getValue();
227230

228-
if (!announcement.isEmpty()) {
229-
buildRunnerHelper.toConsole(announcement);
230-
}
231-
buildRunnerHelper.toConsole(command);
232-
if (launchCommand(command, autoData, monitor, buildRunnerHelper) != 0) {
233-
if (autoData.stopOnFirstBuildError()) {
234-
return false;
231+
if (!announcement.isEmpty()) {
232+
buildRunnerHelper.toConsole(announcement);
233+
}
234+
buildRunnerHelper.toConsole(command);
235+
if (launchCommand(command, autoData, monitor, buildRunnerHelper) != 0) {
236+
if (autoData.stopOnFirstBuildError()) {
237+
return false;
238+
}
235239
}
236240
}
237-
}
238241

239-
240-
String postBuildStep = autoData.getPostbuildStep();
241-
postBuildStep = resolve(postBuildStep, EMPTY_STRING, WHITESPACE, autoData);
242-
if (!postBuildStep.isEmpty()) {
243-
String announcement = autoData.getPostBuildAnouncement();
244-
if (!announcement.isEmpty()) {
245-
buildRunnerHelper.toConsole(announcement);
246-
}
247-
buildRunnerHelper.toConsole(postBuildStep);
248-
if (launchCommand(postBuildStep, autoData, monitor, buildRunnerHelper) != 0) {
249-
return false;
242+
String postBuildStep = autoData.getPostbuildStep();
243+
postBuildStep = resolve(postBuildStep, EMPTY_STRING, WHITESPACE, autoData);
244+
if (!postBuildStep.isEmpty()) {
245+
String announcement = autoData.getPostBuildAnouncement();
246+
if (!announcement.isEmpty()) {
247+
buildRunnerHelper.toConsole(announcement);
248+
}
249+
buildRunnerHelper.toConsole(postBuildStep);
250+
if (launchCommand(postBuildStep, autoData, monitor, buildRunnerHelper) != 0) {
251+
return false;
252+
}
250253
}
251254
}
252255
}

0 commit comments

Comments
 (0)