@Test public void shouldPopulatePropertiesContentWithCustomWorkspace() throws Exception { final String customWorkspaceValue = tmp.newFolder().getAbsolutePath(); String customEnvVarName = "materialize_workspace_path"; String customEnvVarValue = "${WORKSPACE}/materialize_workspace"; FreeStyleProject project = j.createFreeStyleProject(); project.setCustomWorkspace(customWorkspaceValue); EnvVars.masterEnvVars.remove("WORKSPACE"); // ensure build node don't have such var already EnvInjectBuildWrapper envInjectBuildWrapper = new EnvInjectBuildWrapper(); envInjectBuildWrapper.setInfo(withPropContent(customEnvVarName + "=" + customEnvVarValue)); project.getBuildWrappersList().add(envInjectBuildWrapper); FreeStyleBuild build = j.buildAndAssertSuccess(project); // Retrieve build workspace String buildWorkspaceValue = build.getWorkspace().getRemote(); assertThat( "1. Should see actual ws equal to custom", buildWorkspaceValue, equalTo(customWorkspaceValue)); // Compute value with workspace String expectedCustomEnvVarValue = replaceMacro(customEnvVarValue, of("WORKSPACE", buildWorkspaceValue)); assertThat( "2. Property should be resolved with custom ws in build", build, withEnvInjectAction(map(hasEntry(customEnvVarName, expectedCustomEnvVarValue)))); }