diff --git a/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java b/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java index d45cb0a..c01f5fd 100644 --- a/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java +++ b/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java @@ -45,17 +45,30 @@ public class SeleniumhqBuilder extends Builder { private final String suiteFile; private final String resultFile; private final String other; + private final boolean testEnabled; + @DataBoundConstructor public SeleniumhqBuilder(String browser, String startURL, String suiteFile, String resultFile, - String other) { + String other, boolean testEnabled) { this.browser = browser; this.startURL = startURL; this.suiteFile = suiteFile; this.resultFile = resultFile; this.other = other; + this.testEnabled = testEnabled; } + //Left this call in to satisfy the tests. Did not change the tests. + public SeleniumhqBuilder(String browser, String startURL, String suiteFile, String resultFile, + String other) { + this.browser = browser; + this.startURL = startURL; + this.suiteFile = suiteFile; + this.resultFile = resultFile; + this.other = other; + this.testEnabled = true; + } /** * We'll use this from the config.jelly. */ @@ -91,6 +104,13 @@ public String getResultFile() { return resultFile; } + /** + * We'll use this from the config.jelly. + */ + public boolean getTestEnabled() { + return testEnabled; + } + /** * Check if the suiteFile is a URL * @@ -113,7 +133,7 @@ public boolean isURLSuiteFile() { * @throws IOException */ public boolean isFileSuiteFile(AbstractBuild build, Launcher launcher) throws IOException, InterruptedException { - FilePath suiteFilePath = new FilePath(build.getWorkspace(), this.suiteFile); + FilePath suiteFilePath = new FilePath(build.getWorkspace(), this.suiteFile); if (suiteFilePath.exists()) { return suiteFilePath.isDirectory() == false; @@ -142,6 +162,18 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListene return false; } + //if test is not enabled we should mark it as NOT BUILT (rather than success or failure + if(!this.getTestEnabled()) { + listener.getLogger().println("---------------"); + listener.getLogger().println("SKIPPING: Test Suite. '" + this.getSuiteFile() + "' was marked as not enabled"); + listener.getLogger().println("---------------"); + //Let the other surrounding tests determine the build result + //build.setResult(Result.NOT_BUILT); + + //return build so build doesn't get aborted & other tests will get run + return true; + } + // ------------------------------- // Check projet config // ------------------------------- @@ -188,7 +220,7 @@ else if (this.isURLSuiteFile()) { File localWorkspace = new File(build.getRootDir(), "workspace"); File tempSuiteLocal = localWorkspace.createTempFile("tempHtmlSuite", "html"); - + listener.getLogger().println("Try downloading suite file on master"); listener.getLogger().println(" from url : " + this.suiteFile ); listener.getLogger().println(" to file : " + tempSuiteLocal.getPath()); @@ -214,9 +246,15 @@ else if (this.isURLSuiteFile()) return false; } } - else + //see if we've got a jenkins variable. if so just pass it along + else if (this.suiteFile.startsWith("$")) { - // The suiteFile it is a unsuported type + listener.getLogger().println("Suite File Looks Like a Parameter: "+ this.suiteFile); + suiteFile = this.suiteFile; + } + else + { + // The suiteFile it is a unsuported type listener.error("The suiteFile is not a file or an url ! Check your build configuration."); build.setResult(Result.FAILURE); return false; @@ -242,7 +280,7 @@ else if (this.isURLSuiteFile()) cmd.add(this.getStartURL()); cmd.add(suiteFile); cmd.add(resultFile); - + try { String javaCmdString = ""; diff --git a/src/main/resources/hudson/plugins/seleniumhq/SeleniumhqBuilder/config.jelly b/src/main/resources/hudson/plugins/seleniumhq/SeleniumhqBuilder/config.jelly index 482a3c1..37ed0e7 100644 --- a/src/main/resources/hudson/plugins/seleniumhq/SeleniumhqBuilder/config.jelly +++ b/src/main/resources/hudson/plugins/seleniumhq/SeleniumhqBuilder/config.jelly @@ -4,6 +4,9 @@ See global.jelly for a general discussion about jelly script. --> + + +