diff --git a/src/main/java/ru/yandex/qatools/allure/jenkins/AllureReportPublisher.java b/src/main/java/ru/yandex/qatools/allure/jenkins/AllureReportPublisher.java index ce3819e..1731750 100644 --- a/src/main/java/ru/yandex/qatools/allure/jenkins/AllureReportPublisher.java +++ b/src/main/java/ru/yandex/qatools/allure/jenkins/AllureReportPublisher.java @@ -1,5 +1,6 @@ package ru.yandex.qatools.allure.jenkins; +import com.google.common.base.Optional; import hudson.EnvVars; import hudson.FilePath; import hudson.Launcher; @@ -17,6 +18,7 @@ import hudson.tasks.Recorder; import jenkins.model.Jenkins; import jenkins.tasks.SimpleBuildStep; +import org.apache.commons.lang.StringUtils; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; import ru.yandex.qatools.allure.jenkins.callables.AddExecutorInfo; @@ -185,7 +187,7 @@ public String getReport() { } public String getConfigPath() { - return configPath; + return StringUtils.isNotBlank(configPath) ? configPath : null; } @Nonnull @@ -290,7 +292,7 @@ private void generateReport(@Nonnull List resultsPaths, @Nonnull Run resultsPaths, @Nonnull Run resultsPaths, @Nonnull FilePath reportPath, - FilePath configPath) //NOSONAR + public void setConfigFilePath(final FilePath configFilePath) { + this.configFilePath = configFilePath; + } + + public int build(@Nonnull List resultsPaths, @Nonnull FilePath reportPath) //NOSONAR throws IOException, InterruptedException { final String version = commandline.getMajorVersion(launcher); - final ArgumentListBuilder arguments = getArguments(version, resultsPaths, reportPath, configPath); - - + final ArgumentListBuilder arguments = getArguments(version, resultsPaths, reportPath); return launcher.launch().cmds(arguments) .envs(envVars).stdout(listener).pwd(workspace).join(); } private ArgumentListBuilder getArguments(String version, @Nonnull List resultsPaths, - @Nonnull FilePath reportPath, FilePath configPath) + @Nonnull FilePath reportPath) throws IOException, InterruptedException { - return version.startsWith("2") ? getAllure2Arguments(resultsPaths, reportPath, configPath) + return version.startsWith("2") ? getAllure2Arguments(resultsPaths, reportPath) : getAllure1Arguments(resultsPaths, reportPath); } private ArgumentListBuilder getAllure2Arguments(@Nonnull List resultsPaths, - @Nonnull FilePath reportPath, - FilePath configPath) //NOSONAR + @Nonnull FilePath reportPath) //NOSONAR throws IOException, InterruptedException { final ArgumentListBuilder arguments = new ArgumentListBuilder(); arguments.add(commandline.getExecutable(launcher)); @@ -73,9 +75,9 @@ private ArgumentListBuilder getAllure2Arguments(@Nonnull List resultsP arguments.add(CLEAN_OPTION); arguments.add(OUTPUT_DIR_OPTION); arguments.add(reportPath.getRemote()); - if (configPath != null) { + if (configFilePath != null) { arguments.add(CONFIG_OPTION); - arguments.add(configPath.getRemote()); + arguments.add(configFilePath.getRemote()); } return arguments; } diff --git a/src/test/java/ru/yandex/qatools/allure/jenkins/CommandlineIT.java b/src/test/java/ru/yandex/qatools/allure/jenkins/CommandlineIT.java index 7d09803..138b455 100644 --- a/src/test/java/ru/yandex/qatools/allure/jenkins/CommandlineIT.java +++ b/src/test/java/ru/yandex/qatools/allure/jenkins/CommandlineIT.java @@ -52,7 +52,7 @@ public void shouldGenerateReport() throws Exception { results.child("sample-testsuite.xml").copyFrom(is); } FilePath report = new FilePath(folder.getRoot()).child("some folder with (x22) spaces"); - int exitCode = builder.build(Collections.singletonList(results), report, null); + int exitCode = builder.build(Collections.singletonList(results), report); assertThat(exitCode).as("Should exit with code 0").isEqualTo(0); } }