Search in sources :

Example 26 with StringParameterDefinition

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);
}
Also used : StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) EnvironmentVariablesNodeProperty(hudson.slaves.EnvironmentVariablesNodeProperty) Test(org.junit.Test)

Example 27 with StringParameterDefinition

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);
}
Also used : MavenInstallation(hudson.tasks.Maven.MavenInstallation) StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 28 with StringParameterDefinition

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);
}
Also used : MavenInstallation(hudson.tasks.Maven.MavenInstallation) JDK(hudson.model.JDK) StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) LegacyCodeCause(hudson.model.Cause.LegacyCodeCause) StringParameterValue(hudson.model.StringParameterValue) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) ParametersAction(hudson.model.ParametersAction) Test(org.junit.Test)

Example 29 with StringParameterDefinition

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);
}
Also used : BatchFile(hudson.tasks.BatchFile) Shell(hudson.tasks.Shell) StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) CommandInterpreter(hudson.tasks.CommandInterpreter) Issue(org.jvnet.hudson.test.Issue) SmokeTest(org.jvnet.hudson.test.SmokeTest) Test(org.junit.Test)

Example 30 with StringParameterDefinition

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"));
}
Also used : StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) Matchers.containsString(org.hamcrest.Matchers.containsString) FreeStyleProject(hudson.model.FreeStyleProject) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Aggregations

StringParameterDefinition (hudson.model.StringParameterDefinition)95 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)82 Test (org.junit.Test)77 FreeStyleProject (hudson.model.FreeStyleProject)69 ParametersAction (hudson.model.ParametersAction)45 StringParameterValue (hudson.model.StringParameterValue)44 FreeStyleBuild (hudson.model.FreeStyleBuild)43 Issue (org.jvnet.hudson.test.Issue)26 ParameterDefinition (hudson.model.ParameterDefinition)24 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)16 FileWriteBuilder (hudson.plugins.copyartifact.testutils.FileWriteBuilder)15 ArtifactArchiver (hudson.tasks.ArtifactArchiver)15 Shell (hudson.tasks.Shell)15 Cause (hudson.model.Cause)12 ArrayList (java.util.ArrayList)11 CIMessageNotifier (com.redhat.jenkins.plugins.ci.CIMessageNotifier)10 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)10 BooleanParameterDefinition (hudson.model.BooleanParameterDefinition)9 PromotionProcess (hudson.plugins.promoted_builds.PromotionProcess)9 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)9