From b60af529499d58d8921bc2a270a41ca69940fb92 Mon Sep 17 00:00:00 2001 From: gabrielcarioca Date: Wed, 20 Nov 2024 07:48:30 -0300 Subject: [PATCH] fix environment variables resolution (fixes #360, via #371) --- .../allure/jenkins/AllureReportPublisher.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) 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 5505fc0..bec347d 100644 --- a/src/main/java/ru/yandex/qatools/allure/jenkins/AllureReportPublisher.java +++ b/src/main/java/ru/yandex/qatools/allure/jenkins/AllureReportPublisher.java @@ -247,6 +247,7 @@ public AllureReportPublisherDescriptor getDescriptor() { @Override public void perform(final @NonNull Run run, final @NonNull FilePath workspace, + final @NonNull EnvVars env, final @NonNull Launcher launcher, final @NonNull TaskListener listener) throws InterruptedException, IOException { if (isDisabled()) { @@ -260,13 +261,13 @@ public void perform(final @NonNull Run run, + " Check your job's configuration."); } final List results = new ArrayList<>(); - final EnvVars buildEnvVars = BuildUtils.getBuildEnvVars(run, listener); + for (final ResultsConfig resultsConfig : resultsConfigs) { - final String expandedPath = buildEnvVars.expand(resultsConfig.getPath()); + final String expandedPath = env.expand(resultsConfig.getPath()); results.addAll(workspace.act(new FindByGlob(expandedPath))); } prepareResults(results, run, workspace, listener); - generateReport(results, run, workspace, launcher, listener); + generateReport(results, run, workspace, env, launcher, listener); copyResultsToParentIfNeeded(results, run, listener); } @@ -318,7 +319,9 @@ public boolean endBuild() throws InterruptedException, IOException { resultsPaths.add(directory); } } - generateReport(resultsPaths, build, workspace, launcher, listener); + + final EnvVars buildEnvVars = BuildUtils.getBuildEnvVars(build, listener); + generateReport(resultsPaths, build, workspace, buildEnvVars, launcher, listener); for (FilePath resultsPath : resultsPaths) { FilePathUtils.deleteRecursive(resultsPath, listener.getLogger()); } @@ -331,6 +334,7 @@ public boolean endBuild() throws InterruptedException, IOException { private void generateReport(final @NonNull List resultsPaths, final @NonNull Run run, final @NonNull FilePath workspace, + final @NonNull EnvVars env, final @NonNull Launcher launcher, final @NonNull TaskListener listener ) throws IOException, InterruptedException { //NOSONAR @@ -342,13 +346,13 @@ private void generateReport(final @NonNull List resultsPaths, return; } - final EnvVars buildEnvVars = BuildUtils.getBuildEnvVars(run, listener); - setAllureProperties(buildEnvVars); - configureJdk(launcher, listener, buildEnvVars); - final AllureCommandlineInstallation commandline = getCommandline(launcher, listener, buildEnvVars); + + setAllureProperties(env); + configureJdk(launcher, listener, env); + final AllureCommandlineInstallation commandline = getCommandline(launcher, listener, env); final FilePath reportPath = workspace.child(getReport()); - final ReportBuilder builder = new ReportBuilder(launcher, listener, workspace, buildEnvVars, commandline); + final ReportBuilder builder = new ReportBuilder(launcher, listener, workspace, env, commandline); if (getConfigPath() != null && workspace.child(getConfigPath()).exists()) { final FilePath configFilePath = workspace.child(getConfigPath()).absolutize(); listener.getLogger().println("Allure config file: " + configFilePath.absolutize());