use of hudson.model.StringParameterDefinition in project jenkins by jenkinsci.
the class MavenTest method parametersReferencedFromPropertiesShouldRetainBackslashes.
@Test
public void parametersReferencedFromPropertiesShouldRetainBackslashes() throws Exception {
final String properties = "global.path=$GLOBAL_PATH\nmy.path=$PATH\\\\Dir";
final StringParameterDefinition parameter = new StringParameterDefinition("PATH", "C:\\Windows");
final EnvironmentVariablesNodeProperty.Entry envVar = new EnvironmentVariablesNodeProperty.Entry("GLOBAL_PATH", "D:\\Jenkins");
FreeStyleProject project = j.createFreeStyleProject();
// This test implements legacy behavior, when Build Variables are injected by default
project.getBuildersList().add(new Maven("--help", null, null, properties, null, false, null, null, true));
project.addProperty(new ParametersDefinitionProperty(parameter));
j.jenkins.getNodeProperties().replaceBy(Collections.singleton(new EnvironmentVariablesNodeProperty(envVar)));
FreeStyleBuild build = j.waitForCompletion(project.scheduleBuild2(0).waitForStart());
j.assertLogContains("-Dmy.path=C:\\Windows\\Dir", build);
j.assertLogContains("-Dglobal.path=D:\\Jenkins", build);
}
use of hudson.model.StringParameterDefinition in project jenkins by jenkinsci.
the class MavenTest method specialCharsInBuildVariablesPassedAsProperties.
@Issue("JENKINS-26684")
@Test
public void specialCharsInBuildVariablesPassedAsProperties() throws Exception {
MavenInstallation maven = ToolInstallations.configureMaven3();
FreeStyleProject p = j.createFreeStyleProject();
p.getBuildersList().add(new Maven("--help", maven.getName()));
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("tilde", "~"), new StringParameterDefinition("exclamation_mark", "!"), new StringParameterDefinition("at_sign", "@"), new StringParameterDefinition("sharp", "#"), new StringParameterDefinition("dollar", "$"), new StringParameterDefinition("percent", "%"), new StringParameterDefinition("circumflex", "^"), new StringParameterDefinition("ampersand", "&"), new StringParameterDefinition("asterix", "*"), new StringParameterDefinition("parentheses", "()"), new StringParameterDefinition("underscore", "_"), new StringParameterDefinition("plus", "+"), new StringParameterDefinition("braces", "{}"), new StringParameterDefinition("brackets", "[]"), new StringParameterDefinition("colon", ":"), new StringParameterDefinition("semicolon", ";"), new StringParameterDefinition("quote", "\""), new StringParameterDefinition("apostrophe", "'"), new StringParameterDefinition("backslash", "\\"), new StringParameterDefinition("pipe", "|"), new StringParameterDefinition("angle_brackets", "<>"), new StringParameterDefinition("comma", ","), new StringParameterDefinition("period", "."), new StringParameterDefinition("slash", "/"), new StringParameterDefinition("question_mark", "?"), new StringParameterDefinition("space", " ")));
FreeStyleBuild build = j.buildAndAssertSuccess(p);
}
use of hudson.model.StringParameterDefinition in project jenkins by jenkinsci.
the class MavenTest method withParameter.
@Test
public void withParameter() throws Exception {
MavenInstallation maven = ToolInstallations.configureDefaultMaven();
String mavenHome = maven.getHome();
String mavenHomeVar = "${VAR_MAVEN}" + mavenHome.substring(3);
String mavenVar = mavenHome.substring(0, 3);
MavenInstallation varMaven = new MavenInstallation("varMaven", mavenHomeVar, JenkinsRule.NO_PROPERTIES);
j.jenkins.getDescriptorByType(Maven.DescriptorImpl.class).setInstallations(maven, varMaven);
JDK jdk = j.jenkins.getJDK("default");
String javaHome = jdk.getHome();
String javaHomeVar = "${VAR_JAVA}" + javaHome.substring(3);
String javaVar = javaHome.substring(0, 3);
JDK varJDK = new JDK("varJDK", javaHomeVar);
j.jenkins.getJDKs().add(varJDK);
FreeStyleProject project = j.createFreeStyleProject();
project.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("VAR_MAVEN", "XXX"), new StringParameterDefinition("VAR_JAVA", "XXX")));
project.getBuildersList().add(new Maven("--help", varMaven.getName()));
project.setJDK(varJDK);
FreeStyleBuild build = project.scheduleBuild2(0, new LegacyCodeCause(), new ParametersAction(new StringParameterValue("VAR_MAVEN", mavenVar), new StringParameterValue("VAR_JAVA", javaVar))).get();
j.assertBuildStatusSuccess(build);
}
use of hudson.model.StringParameterDefinition 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.model.StringParameterDefinition in project jenkins by jenkinsci.
the class AlternativeUiTextProviderTest method basicsWithParameter.
/**
* Makes sure that {@link AlternativeUiTextProvider} actually works with a parameterized Job.
*/
@Test
@Issue("JENKINS-41757")
public void basicsWithParameter() throws Exception {
Impl.oldschool = false;
FreeStyleProject p = j.createFreeStyleProject("aaa");
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("FOO", null)));
String pageText = j.createWebClient().getPage(p).asNormalizedText();
assertThat(pageText, containsString("newschool:aaa"));
Impl.oldschool = true;
pageText = j.createWebClient().getPage(p).asNormalizedText();
assertThat(pageText, containsString("oldschool:aaa"));
}
Aggregations