use of hudson.tasks.CommandInterpreter in project jenkins by jenkinsci.
the class LauncherTest method overwriteSystemEnvVars.
@Issue("JENKINS-19926")
@Test
public void overwriteSystemEnvVars() throws Exception {
Map<String, String> env = new HashMap<>();
env.put("jenkins_19926", "original value");
Slave slave = rule.createSlave(new EnvVars(env));
FreeStyleProject project = rule.createFreeStyleProject();
project.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("jenkins_19926", "${jenkins_19926} and new value")));
final CommandInterpreter script = Functions.isWindows() ? new BatchFile("echo %jenkins_19926%") : new Shell("echo ${jenkins_19926}");
project.getBuildersList().add(script);
project.setAssignedNode(slave.getComputer().getNode());
FreeStyleBuild build = rule.buildAndAssertSuccess(project);
rule.assertLogContains("original value and new value", build);
}
use of hudson.tasks.CommandInterpreter in project jenkins by jenkinsci.
the class LauncherTest method correctlyExpandEnvVars.
@Issue("JENKINS-19488")
@Test
public void correctlyExpandEnvVars() throws Exception {
FreeStyleProject project = rule.createFreeStyleProject();
project.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("A", "aaa"), new StringParameterDefinition("C", "ccc"), new StringParameterDefinition("B", "$A$C")));
final CommandInterpreter script = Functions.isWindows() ? new BatchFile("echo %A% %B% %C%") : new Shell("echo $A $B $C");
project.getBuildersList().add(script);
FreeStyleBuild build = rule.buildAndAssertSuccess(project);
rule.assertLogContains("aaa aaaccc ccc", build);
}
use of hudson.tasks.CommandInterpreter in project postbuildscript-plugin by jenkinsci.
the class CommandExecutor method buildArguments.
private List<String> buildArguments(Command command, String scriptContent) throws IOException, InterruptedException {
CommandInterpreter interpreter = createInterpreter(scriptContent);
FilePath scriptFile = interpreter.createScriptFile(workspace);
List<String> args = new ArrayList<>(Arrays.asList(interpreter.buildCommandLine(scriptFile)));
args.addAll(command.getParameters());
return args;
}
Aggregations