Java 类hudson.model.StringParameterDefinition 实例源码

项目:run-selector-plugin    文件:ParameterizedRunSelectorTest.java   
/**
 * Also applicable for workflow jobs.
 */
@Issue("JENKINS-30357")
@Test
public void testWorkflow() throws Exception {
    FreeStyleProject jobToSelect = j.createFreeStyleProject();
    Run runToSelect = j.assertBuildStatusSuccess(jobToSelect.scheduleBuild2(0));

    WorkflowJob selecter = createWorkflowJob();

    ParameterDefinition paramDef = new StringParameterDefinition(
            "SELECTOR", "<StatusRunSelector><buildStatus>STABLE</buildStatus></StatusRunSelector>"
    );
    selecter.addProperty(new ParametersDefinitionProperty(paramDef));

    selecter.setDefinition(new CpsFlowDefinition(String.format("" +
            "def runWrapper = selectRun job: '%s', " +
            " selector: [$class: 'ParameterizedRunSelector', parameterName: '${SELECTOR}'] \n" +
            "assert(runWrapper.id == '%s')", jobToSelect.getFullName(), runToSelect.getId())));

    j.assertBuildStatusSuccess(selecter.scheduleBuild2(0));
}
项目:run-selector-plugin    文件:ParameterizedRunFilterTest.java   
@Test
public void testIsSelectableEmptyParameter() throws Exception {
    WorkflowJob selecter = j.jenkins.createProject(
        WorkflowJob.class,
        RandomStringUtils.randomAlphanumeric(7)
    );
    selecter.addProperty(new ParametersDefinitionProperty(
        new StringParameterDefinition(
            "FILTER",
            "",
            "description"
        )
    ));
    selecter.setDefinition(new CpsFlowDefinition(String.format(
        "def runWrapper = selectRun"
        + " job: '%s',"
        + " filter: [$class: 'ParameterizedRunFilter', parameter: '${FILTER}'],"
        + " verbose: true;"
        + "assert(runWrapper.id == '%s')",
        jobToSelect.getFullName(),
        runToSelect2.getId()
    )));

    j.assertBuildStatusSuccess(selecter.scheduleBuild2(0));
}
项目:delivery-pipeline-plugin    文件:PipelineVersionContributorTest.java   
@Test
@Issue("JENKINS-28848")
public void testWithBuildNameSetterPluginAndAdditionalParameters() throws Exception {
    FreeStyleProject a = jenkins.createFreeStyleProject("a");
    FreeStyleProject b = jenkins.createFreeStyleProject("b");

    a.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("BUILD_VERSION", "DEFAULT_VALUE")));
    a.getPublishersList().add(new BuildTrigger("b", false));
    a.getBuildWrappersList().add(new PipelineVersionContributor(true, "1.0.0.$BUILD_NUMBER"));
    b.getBuildWrappersList().add(new BuildNameSetter("$PIPELINE_VERSION"));


    jenkins.getInstance().rebuildDependencyGraph();
    jenkins.setQuietPeriod(0);

    jenkins.buildAndAssertSuccess(a);
    jenkins.waitUntilNoActivity();

    assertEquals("1.0.0.1", a.getLastBuild().getDisplayName());
    assertEquals("1.0.0.1", b.getLastBuild().getDisplayName());
    assertEquals("1.0.0.1", a.getLastBuild().getBuildVariableResolver().resolve(PIPELINE_VERSION));
    assertEquals("1.0.0.1", b.getLastBuild().getBuildVariableResolver().resolve(PIPELINE_VERSION));
}
项目:yaml-project-plugin    文件:YamlDecoratorTest.java   
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);

  project = jenkins.createFreeStyleProject("test");

  project.getBuildersList().add(new hudson.tasks.Shell("echo $foo"));
  // Make sure we don't clobber pre-existing properties when we workaround the
  // missing null check.
  project.addProperty(new ParametersDefinitionProperty(
      new StringParameterDefinition("foo", "bar")));
}
项目:leroy_jenkins    文件:LeroyStringParameterDefinition.java   
@Override
public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue) {
    if (defaultValue instanceof LeroyStringParameterValue) {
        LeroyStringParameterValue value = (LeroyStringParameterValue) defaultValue;
        return new StringParameterDefinition(getName(), value.value, getDescription());
    } else {
        return this;
    }
}
项目:p4-jenkins    文件:ReviewAction.java   
public void doBuild(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {

        project.checkPermission(AbstractProject.BUILD);

        List<ParameterValue> values = new ArrayList<ParameterValue>();
        List<ParameterDefinition> defs = new ArrayList<ParameterDefinition>();

        Enumeration<?> names = req.getParameterNames();
        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            defs.add(new StringParameterDefinition(name, null));
        }

        for (ParameterDefinition d : defs) {
            StringParameterValue value = (StringParameterValue) d.createValue(req);
            if (value != null && value.value != null && !value.value.isEmpty()) {
                values.add(value);
            }
        }

        // Schedule build
        TimeDuration delay = new TimeDuration(project.getQuietPeriod());
        CauseAction cause = new CauseAction(new Cause.UserIdCause());

        List<ParameterValue> internalParams = extractAndRemoveInternalParameters(values);
        ParametersAction params = new SafeParametersAction(values, internalParams);

        Jenkins j = Jenkins.getInstance();
        if (j != null) {
            Queue queue = j.getQueue();
            queue.schedule(project, delay.getTime(), params, cause);

            // send the user back to the job top page.
            rsp.sendRedirect("../");
        }
    }
项目:p4-jenkins    文件:ReviewAction.java   
private List<ParameterDefinition> getParameterDefinitions() {
    List<ParameterDefinition> swarm = new ArrayList<ParameterDefinition>();

    // Swarm parameters
    swarm.add(new StringParameterDefinition(ReviewProp.REVIEW.getProp(), null));
    swarm.add(new StringParameterDefinition(ReviewProp.CHANGE.getProp(), null));
    swarm.add(new StringParameterDefinition(ReviewProp.STATUS.getProp(), null));
    swarm.add(new StringParameterDefinition(ReviewProp.PASS.getProp(), null));
    swarm.add(new StringParameterDefinition(ReviewProp.FAIL.getProp(), null));

    // Custom parameters
    swarm.add(new StringParameterDefinition(ReviewProp.LABEL.toString(), null));

    return swarm;
}
项目:jenkins-inheritance-plugin    文件:TestParameterInheritance.java   
private void addParameters(
        InheritanceProject ip, List<StringParameterValue> values) throws IOException {
    List<ParameterDefinition> pDefs = new LinkedList<>();
    for (StringParameterValue pv : values) {
        pDefs.add(new StringParameterDefinition(pv.getName(), pv.value));
    }
    ParametersDefinitionProperty pdp =
            new ParametersDefinitionProperty(pDefs);
    ip.addProperty(pdp);
}
项目:delivery-pipeline-plugin    文件:DeliveryPipelineViewTest.java   
@Test
public void testRebuild() throws Exception {
    FreeStyleProject projectA = jenkins.createFreeStyleProject("A");
    FreeStyleProject projectB = jenkins.createFreeStyleProject("B");
    projectB.addProperty(new ParametersDefinitionProperty(
            new StringParameterDefinition("BUILD_VERSION", "DEFAULT_VALUE")));
    projectA.getPublishersList().add(
            new hudson.plugins.parameterizedtrigger.BuildTrigger(
                    new BuildTriggerConfig("b", ResultCondition.SUCCESS,
                            new PredefinedBuildParameters("VERSION=$BUILD_NUMBER"))));

    jenkins.getInstance().rebuildDependencyGraph();

    DeliveryPipelineView view = new DeliveryPipelineView("Pipeline");
    jenkins.getInstance().addView(view);

    jenkins.buildAndAssertSuccess(projectA);
    jenkins.waitUntilNoActivity();

    assertNotNull(projectA.getLastBuild());
    assertNotNull(projectB.getLastBuild());

    final AbstractBuild<?, ?> b1 = projectB.getLastBuild();

    view.triggerRebuild("B", "1");
    jenkins.waitUntilNoActivity();
    assertEquals(2, projectB.getLastBuild().getNumber());
    assertEqualsList(b1.getActions(ParametersAction.class),
            projectB.getLastBuild().getActions(ParametersAction.class));
}
项目:delivery-pipeline-plugin    文件:GuiFunctionalIT.java   
@Test
public void testTriggerNewParameterizedPipeline() throws Exception {

    FreeStyleProject start = jenkins.createFreeStyleProject("Start");
    start.addProperty(new ParametersDefinitionProperty(
            new StringParameterDefinition("key2", "value2")
            ));
    jenkins.createFreeStyleProject("End");
    start.getPublishersList().add(new BuildTrigger("End", true));

    jenkins.getInstance().rebuildDependencyGraph();

    DeliveryPipelineView view = new DeliveryPipelineView("Pipeline");
    List<DeliveryPipelineView.ComponentSpec> specs = new ArrayList<>();
    specs.add(new DeliveryPipelineView.ComponentSpec("Component", "Start", NONE, DO_NOT_SHOW_UPSTREAM));
    view.setComponentSpecs(specs);
    view.setAllowPipelineStart(true);

    jenkins.getInstance().addView(view);

    DeliveryPipelinePage page =
            new DeliveryPipelinePage(webDriver, jenkins.getURL().toExternalForm(), "view/Pipeline");
    page.open();
    page.triggerNewParameterizedPipelineBuild("0");

    jenkins.waitUntilNoActivity();

    assertNotNull(start.getLastBuild());
}