Skip to content

Commit

Permalink
BUM-213 Add "Fail run in ALM if analysis fail" checkbox for testset
Browse files Browse the repository at this point in the history
runner step
  • Loading branch information
aymanBA92 committed Sep 4, 2018
1 parent 77a482f commit bcb0d84
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
Expand Up @@ -41,6 +41,7 @@
*
*/
public class RunTestSetBuildStep extends Builder implements SimpleBuildStep {
private static final String TEST_SET_FAIL_BUILD_MESSAGE = "Bumblebee: Fail run in ALM if analysis fail flag is set to true -> mark build as failed.";
private static final String TEST_SET_DELIMETER = "\r\n";
private final String domain;
private final String project;
Expand All @@ -49,6 +50,7 @@ public class RunTestSetBuildStep extends Builder implements SimpleBuildStep {
private final String testSets;
private final String outputDirPath;
private final int timeOut;
private final boolean failRunInAlmIfAnalysisFail;

/**
* Constructor.
Expand All @@ -71,14 +73,15 @@ public class RunTestSetBuildStep extends Builder implements SimpleBuildStep {
*/
@DataBoundConstructor
public RunTestSetBuildStep(final String domain, final String project, final String runMode, final String host, final String testSets,
final String outputDirPath, final int timeOut) {
final String outputDirPath, final int timeOut, final boolean failRunInAlmIfAnalysisFail) {
this.domain = domain;
this.project = project;
this.runMode = AlmRunMode.valueOf(runMode.toUpperCase());
this.host = host;
this.testSets = testSets;
this.outputDirPath = outputDirPath;
this.timeOut = timeOut;
this.failRunInAlmIfAnalysisFail = failRunInAlmIfAnalysisFail;
}

@Override
Expand All @@ -89,13 +92,15 @@ public void perform(final Run<?, ?> run, final FilePath workspace, final Launche
final RunTestSetTask task = new RunTestSetTask(listener, run.getExecutor().getOwner().getNode().getRootPath(), workspace,
createParameters(run.getEnvironment(listener)));
final int returnCode = launcher.getChannel().call(task);
if (returnCode != 0) {
throw new AbortException("Test set execution failed. See logs for details.");
if (returnCode != 0 && failRunInAlmIfAnalysisFail) {
throw new AbortException(TEST_SET_FAIL_BUILD_MESSAGE);
}
} catch (final IOException e) {
throw e;
} catch (final Exception e) {
throw new IOException(e.getMessage(), e);
if (failRunInAlmIfAnalysisFail) {
throw new AbortException(TEST_SET_FAIL_BUILD_MESSAGE);
} else {
listener.getLogger().println("Bumblebee: Fail run in ALM if analysis fail flag is set to false -> ignore errors in the build.");
}
}
}

Expand Down Expand Up @@ -169,6 +174,13 @@ public int getTimeOut() {
return timeOut;
}

/**
* @return true, if is fail run in ALM if analysis fail.
*/
public boolean isFailRunInAlmIfAnalysisFail() {
return failRunInAlmIfAnalysisFail;
}

/**
* Descriptor for {@link RunTestSetBuildStep}.
*
Expand Down
Expand Up @@ -28,7 +28,10 @@
</f:entry>
<f:entry title="Execution Timeout" field="timeOut" >
<f:number name="timeOut" default="0" value="${instance.getTimeOut()}" clazz="required" checkMessage="Must be a valid integer" />
</f:entry>
</f:entry>
<f:entry title="Fail run in ALM if analysis fail" field="failRunInAlmIfAnalysisFail">
<f:checkbox name="failRunInAlmIfAnalysisFail" checked="${instance.isFailRunInAlmIfAnalysisFail()}" default="false"/>
</f:entry>
</table>
</d:taglib>
</f:block>
Expand Down
@@ -0,0 +1,5 @@
<div>
If checked, the build will be marked as failed if for any
reason the plugin was not able to run Testsets in ALM. This could be due
to Bumblebee server issues, ALM server issues, network issues, etc.
</div>

0 comments on commit bcb0d84

Please sign in to comment.