Skip to content
Permalink
Browse files

JENKINS-27593: Do not try to export test results for canceled or brok…

  • Loading branch information...
stolp
stolp committed Mar 25, 2015
1 parent 8fd406f commit 6048cb47c4cd17cf9aaf4be56880767a6e664d10
Showing with 48 additions and 36 deletions.
  1. +48 −36 src/main/java/hudson/plugins/klaros/KlarosTestResultPublisher.java
@@ -360,47 +360,59 @@ public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher,
final BuildListener listener) {

boolean result = false;
if (Result.SUCCESS.equals(build.getResult())
|| Result.UNSTABLE.equals(build.getResult())) {

FilePath ws = build.getWorkspace();
if (ws == null) {
listener.error("No workspace defined!");
build.setResult(Result.FAILURE);
result = false;
} else {
for (ResultSet resultSet : getResultSets()) {
if (StringUtils.isEmpty(resultSet.getSpec())) {
listener.getLogger().println(
"Empty result spec implementation detected");
} else {
listener.getLogger().println(
"The test result(s) contained in target "
+ resultSet.getSpec()
+ " will be exported to the "
+ "Klaros-Testmanagement Server at "
+ getUrl(url) + ".");
listener.getLogger().println(
"With parameters Project[" + config + "], Environment["
+ env + "], SUT[" + sut + "] and Type[" + type
+ "].");

try {
FileCallableImplementation exporter = new FileCallableImplementation(
listener);
exporter.setKlarosUrl(getKlarosUrl(url));
exporter.setResultSet(resultSet);
ws.act(exporter);

} catch (IOException e) {
listener.getLogger().println(
"Failure to export test result(s).");
e.printStackTrace(listener.getLogger());
} catch (InterruptedException e) {
listener.getLogger().println(
"Failure to export test result(s).");
e.printStackTrace(listener.getLogger());
}

FilePath ws = build.getWorkspace();
if (ws == null) {
listener.error("No workspace defined!");
build.setResult(Result.FAILURE);
result = false;
} else {
for (ResultSet resultSet : getResultSets()) {
if (StringUtils.isEmpty(resultSet.getSpec())) {
listener.getLogger().println(
"Empty result spec implementation detected");
} else {
listener.getLogger().println(
"The test result(s) contained in target "
+ resultSet.getSpec() + " will be exported to the "
+ "Klaros-Testmanagement Server at " + getUrl(url)
+ ".");
listener.getLogger().println(
"With parameters Project[" + config + "], Environment[" + env
+ "], SUT[" + sut + "] and Type[" + type + "].");
listener.getLogger().println(
"Test result(s) successfully exported.");

try {
FileCallableImplementation exporter = new FileCallableImplementation(
listener);
exporter.setKlarosUrl(getKlarosUrl(url));
exporter.setResultSet(resultSet);
ws.act(exporter);

} catch (IOException e) {
listener.getLogger().println("Failure to export test result(s).");
e.printStackTrace(listener.getLogger());
} catch (InterruptedException e) {
listener.getLogger().println("Failure to export test result(s).");
e.printStackTrace(listener.getLogger());
result = true;
}

listener.getLogger().println("Test result(s) successfully exported.");

result = true;
}
}
} else {
listener.getLogger().println(
"Skipping export of test results to Klaros-Testmangement due to build status");
result = true;
}
return result;
}

0 comments on commit 6048cb4

Please sign in to comment.
You can’t perform that action at this time.