This is an automated email from the ASF dual-hosted git repository.

mattcasters pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new 5e2dabf5a9 Fix project variable resolution in environment file paths 
(#8246)
5e2dabf5a9 is described below

commit 5e2dabf5a9093c1d706787eb8e8b115b9567a34c
Author: Gabriel Dutra <[email protected]>
AuthorDate: Thu Sep 3 12:07:19 2026 -0700

    Fix project variable resolution in environment file paths (#8246)
---
 .../org/apache/hop/projects/project/Project.java   | 10 +++++++
 .../apache/hop/projects/project/ProjectTest.java   | 34 ++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git 
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/Project.java
 
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/Project.java
index 522e66f97f..00f1010dc8 100644
--- 
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/Project.java
+++ 
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/Project.java
@@ -256,6 +256,10 @@ public class Project extends ConfigFile implements 
IConfigFile {
       variables.setVariable(ProjectsUtil.VARIABLE_PROJECT_HOME, realValue);
     }
 
+    // Project variables can be used in environment configuration file paths.
+    //
+    applyProjectVariables(variables);
+
     // Apply the described variables from the various configuration files in 
the given order...
     //
     for (String configurationFile : configurationFiles) {
@@ -314,6 +318,12 @@ public class Project extends ConfigFile implements 
IConfigFile {
       String realValue = variables.resolve(dataSetsCsvFolder);
       variables.setVariable(ProjectsUtil.VARIABLE_HOP_DATASETS_FOLDER, 
realValue);
     }
+    // Keep project variables as the final values when a configuration file 
defines the same name.
+    //
+    applyProjectVariables(variables);
+  }
+
+  private void applyProjectVariables(IVariables variables) {
     for (DescribedVariable variable : getDescribedVariables()) {
       if (variable.getName() != null) {
         variables.setVariable(variable.getName(), variable.getValue());
diff --git 
a/plugins/misc/projects/src/test/java/org/apache/hop/projects/project/ProjectTest.java
 
b/plugins/misc/projects/src/test/java/org/apache/hop/projects/project/ProjectTest.java
index db7fa3289e..44e663ac69 100644
--- 
a/plugins/misc/projects/src/test/java/org/apache/hop/projects/project/ProjectTest.java
+++ 
b/plugins/misc/projects/src/test/java/org/apache/hop/projects/project/ProjectTest.java
@@ -30,6 +30,9 @@ import java.util.Comparator;
 import java.util.stream.Stream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
+import org.apache.hop.core.config.DescribedVariablesConfigFile;
+import org.apache.hop.core.logging.HopLogStore;
+import org.apache.hop.core.variables.DescribedVariable;
 import org.apache.hop.core.variables.IVariables;
 import org.apache.hop.core.variables.Variables;
 import org.apache.hop.projects.config.ProjectsConfig;
@@ -200,6 +203,37 @@ public class ProjectTest {
     assertEquals(childHome.toString(), 
variables.getVariable(ProjectsUtil.VARIABLE_PROJECT_HOME));
   }
 
+  @Test
+  public void testProjectVariableResolvesEnvironmentConfigurationFilePath() 
throws Exception {
+    HopLogStore.init();
+    tempRoot = Files.createTempDirectory("hop-project-environment-variable");
+    Path projectHome = tempRoot.resolve("project");
+    Path configFolder = projectHome.resolve("config");
+    Files.createDirectories(configFolder);
+
+    Path environmentFile = configFolder.resolve("environment.json");
+    DescribedVariablesConfigFile configFile =
+        new DescribedVariablesConfigFile(environmentFile.toString());
+    configFile.setDescribedVariable(new DescribedVariable("ENVIRONMENT_VALUE", 
"loaded", ""));
+    configFile.saveToFile();
+
+    ProjectConfig projectConfig =
+        new ProjectConfig(
+            "project", projectHome.toString(), 
ProjectsConfig.DEFAULT_PROJECT_CONFIG_FILENAME);
+    Project project = new Project();
+    project
+        .getDescribedVariables()
+        .add(
+            new DescribedVariable(
+                "CONFIG_HOME", "${" + ProjectsUtil.VARIABLE_PROJECT_HOME + 
"}/config", ""));
+
+    IVariables variables = new Variables();
+    project.modifyVariables(
+        variables, projectConfig, 
java.util.List.of("${CONFIG_HOME}/environment.json"), "dev");
+
+    assertEquals("loaded", variables.getVariable("ENVIRONMENT_VALUE"));
+  }
+
   @Test
   public void testParentProjectFoldersSerialization() throws Exception {
     File tempFile = Files.createTempFile("project-config-parent-folders", 
".json").toFile();

Reply via email to