Skip to content

Commit

Permalink
fix environment variables resolution (fixes #360, via #371)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcarioca authored Nov 20, 2024
1 parent ccd1e5d commit b60af52
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -260,13 +261,13 @@ public void perform(final @NonNull Run<?, ?> run,
+ " Check your job's configuration.");
}
final List<FilePath> 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);
}

Expand Down Expand Up @@ -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());
}
Expand All @@ -331,6 +334,7 @@ public boolean endBuild() throws InterruptedException, IOException {
private void generateReport(final @NonNull List<FilePath> 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
Expand All @@ -342,13 +346,13 @@ private void generateReport(final @NonNull List<FilePath> 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());
Expand Down

0 comments on commit b60af52

Please sign in to comment.