Search in sources :

Example 1 with BooleanParameterDefinition

use of hudson.model.BooleanParameterDefinition in project selenium_java by sergueik.

the class WhenSchedulingJob method testParameterisedJobShouldSaveAllParameters.

@Test
public void testParameterisedJobShouldSaveAllParameters() throws Exception {
    final FreeStyleProject project = createFreeStyleProject("ParameterisedJob");
    // set parameters
    final ParameterDefinition param1 = new StringParameterDefinition("myStringParam", "myStringValue", "My String Parameter");
    final ParameterDefinition param2 = new BooleanParameterDefinition("myBooleanParam", false, "My Boolean Parameter");
    project.addProperty(new ParametersDefinitionProperty(param1, param2));
    // enable audit2db plugin
    final DbAuditPublisher plugin = getPlugin();
    project.getPublishersList().add((Publisher) plugin);
    // build now
    final Future<FreeStyleBuild> futureBuild = project.scheduleBuild2(0);
    final FreeStyleBuild build = futureBuild.get();
    Assert.assertNotNull(build);
    Assert.assertEquals("Unexpected build result", Result.SUCCESS, build.getResult());
    // check data persistence
    final BuildDetailsRepository repository = plugin.getRepository();
    final BuildDetails actual = repository.getBuildDetailsForBuild(build);
    final BuildDetails expected = new BuildDetailsImpl(build);
    Assert.assertEquals("Unexpected build details", expected, actual);
    Assert.assertNotNull("Unexpected null end date", actual.getEndDate());
    Assert.assertTrue("Unexpected duration", actual.getDuration() > 0L);
    Assert.assertEquals("Unexpected number of params", 2, actual.getParameters().size());
}
Also used : BuildDetailsImpl(org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl) StringParameterDefinition(hudson.model.StringParameterDefinition) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) BuildDetailsRepository(org.jenkins.plugins.audit2db.data.BuildDetailsRepository) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) StringParameterDefinition(hudson.model.StringParameterDefinition) ParameterDefinition(hudson.model.ParameterDefinition) DbAuditPublisher(org.jenkins.plugins.audit2db.DbAuditPublisher) Test(org.junit.Test)

Example 2 with BooleanParameterDefinition

use of hudson.model.BooleanParameterDefinition in project workflow-cps-plugin by jenkinsci.

the class ParamsVariableTest method smokes.

@Issue("JENKINS-27295")
@Test
public void smokes() throws Exception {
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    p.setDefinition(new CpsFlowDefinition("echo(/TEXT=${params.TEXT} FLAG=${params.FLAG ? 'yes' : 'no'} PASS=${params.PASS}/)", true));
    p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("TEXT", ""), new BooleanParameterDefinition("FLAG", false, null), new PasswordParameterDefinition("PASS", "", null)));
    WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("TEXT", "hello"), new BooleanParameterValue("FLAG", true), new PasswordParameterValue("PASS", "s3cr3t"))));
    r.assertLogContains("TEXT=hello", b);
    r.assertLogContains("FLAG=yes", b);
    r.assertLogContains("PASS=s3cr3t", b);
}
Also used : StringParameterDefinition(hudson.model.StringParameterDefinition) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) BooleanParameterValue(hudson.model.BooleanParameterValue) PasswordParameterDefinition(hudson.model.PasswordParameterDefinition) StringParameterValue(hudson.model.StringParameterValue) PasswordParameterValue(hudson.model.PasswordParameterValue) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) ParametersAction(hudson.model.ParametersAction) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 3 with BooleanParameterDefinition

use of hudson.model.BooleanParameterDefinition in project workflow-cps-plugin by jenkinsci.

the class SnippetizerTest method generateSnippetForBuildTrigger.

@Issue("JENKINS-26093")
@Test
public void generateSnippetForBuildTrigger() throws Exception {
    MockFolder d1 = r.createFolder("d1");
    FreeStyleProject ds = d1.createProject(FreeStyleProject.class, "ds");
    MockFolder d2 = r.createFolder("d2");
    // Really this would be a WorkflowJob, but we cannot depend on that here, and it should not matter since we are just looking for Job:
    FreeStyleProject us = d2.createProject(FreeStyleProject.class, "us");
    ds.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("key", ""), new BooleanParameterDefinition("flag", false, "")));
    String snippet;
    if (StringParameterDefinition.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) {
        snippet = "build job: '../d1/ds', parameters: [string(name: 'key', value: 'stuff'), booleanParam(name: 'flag', value: true)]";
    } else {
        // TODO 2.x delete
        snippet = "build job: '../d1/ds', parameters: [[$class: 'StringParameterValue', name: 'key', value: 'stuff'], [$class: 'BooleanParameterValue', name: 'flag', value: true]]";
    }
    st.assertGenerateSnippet("{'stapler-class':'" + BuildTriggerStep.class.getName() + "', 'job':'../d1/ds', 'parameter': [{'name':'key', 'value':'stuff'}, {'name':'flag', 'value':true}]}", snippet, us.getAbsoluteUrl() + "configure");
}
Also used : StringParameterDefinition(hudson.model.StringParameterDefinition) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) MockFolder(org.jvnet.hudson.test.MockFolder) FreeStyleProject(hudson.model.FreeStyleProject) BuildTriggerStep(org.jenkinsci.plugins.workflow.support.steps.build.BuildTriggerStep) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 4 with BooleanParameterDefinition

use of hudson.model.BooleanParameterDefinition in project hudson-2.x by hudson.

the class CascadingParameterDefinitionPropertiesTest method setUp.

@Before
public void setUp() throws Exception {
    p1 = new FreeStyleProjectMock("p1");
    p2 = new FreeStyleProjectMock("p2");
    p3 = new FreeStyleProjectMock("p3");
    p2.setCascadingProject(p1);
    CascadingUtil.linkCascadingProjectsToChild(p1, "p2");
    p3.setCascadingProject(p2);
    CascadingUtil.linkCascadingProjectsToChild(p2, "p3");
    Hudson hudson = createMock(Hudson.class);
    expect(hudson.getItem("p2")).andReturn(p2).anyTimes();
    expect(hudson.getItem("p3")).andReturn(p3).anyTimes();
    mockStatic(Hudson.class);
    expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
    replay(Hudson.class, hudson);
    propertyKey = Job.PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME;
    List<ParameterDefinition> parameterDefinitionList = new ArrayList<ParameterDefinition>();
    parameterDefinitionList.add(new BooleanParameterDefinition("name", true, "d1"));
    ParametersDefinitionProperty property = new ParametersDefinitionProperty(parameterDefinitionList);
    copyOnWriteList = new CopyOnWriteList<ParametersDefinitionProperty>();
    copyOnWriteList.add(property);
}
Also used : FreeStyleProjectMock(hudson.model.FreeStyleProjectMock) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) Hudson(hudson.model.Hudson) ArrayList(java.util.ArrayList) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) ParameterDefinition(hudson.model.ParameterDefinition) Before(org.junit.Before)

Aggregations

BooleanParameterDefinition (hudson.model.BooleanParameterDefinition)4 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)4 StringParameterDefinition (hudson.model.StringParameterDefinition)3 Test (org.junit.Test)3 FreeStyleProject (hudson.model.FreeStyleProject)2 ParameterDefinition (hudson.model.ParameterDefinition)2 Issue (org.jvnet.hudson.test.Issue)2 BooleanParameterValue (hudson.model.BooleanParameterValue)1 FreeStyleBuild (hudson.model.FreeStyleBuild)1 FreeStyleProjectMock (hudson.model.FreeStyleProjectMock)1 Hudson (hudson.model.Hudson)1 ParametersAction (hudson.model.ParametersAction)1 PasswordParameterDefinition (hudson.model.PasswordParameterDefinition)1 PasswordParameterValue (hudson.model.PasswordParameterValue)1 StringParameterValue (hudson.model.StringParameterValue)1 ArrayList (java.util.ArrayList)1 DbAuditPublisher (org.jenkins.plugins.audit2db.DbAuditPublisher)1 BuildDetailsRepository (org.jenkins.plugins.audit2db.data.BuildDetailsRepository)1 BuildDetailsImpl (org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl)1 BuildDetails (org.jenkins.plugins.audit2db.model.BuildDetails)1