Package hudson.model

Examples of hudson.model.ParametersDefinitionProperty


        return this;
    }
   
    private void withParameterDefinitions(ParameterDefinition... definitions) {
        when(project.getProperty(ParametersDefinitionProperty.class)).thenReturn(
                new ParametersDefinitionProperty(definitions));
    }
View Full Code Here


    @Bug(25226)
    public void testCheckParamSubstitutionOrder() throws Exception {
        final String projectPath_format = "//depot1/%s/... //client/path1/...";
               
        final FreeStyleProject prj = createFreeStyleProject();
        prj.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("PARAM1", "defaultValue")));
         
        PerforceToolInstallation stubInstallation = new PerforceToolInstallation("p4_stub", "echo", new LinkedList<ToolProperty<?>>());
        PerforceToolInstallation.DescriptorImpl descriptor = (PerforceToolInstallation.DescriptorImpl) Hudson.getInstance().getDescriptor(PerforceToolInstallation.class);
        descriptor.setInstallations(new PerforceToolInstallation[] { stubInstallation });
        descriptor.save();
View Full Code Here

            @Override public void evaluate() throws Throwable {
                @SuppressWarnings("deprecation")
                String slaveRoot = story.j.createTmpDir().getPath();
                jenkins().addNode(new DumbSlave("slave", "dummy", slaveRoot, "2", Node.Mode.NORMAL, "", story.j.createComputerLauncher(null), RetentionStrategy.NOOP, Collections.<NodeProperty<?>>emptyList()));
                p = jenkins().createProject(WorkflowJob.class, "demo");
                p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("FLAG", null)));
                p.setDefinition(new CpsFlowDefinition(
                        "node('slave') {\n" + // this locks the WS
                                "    sh('echo default=`basename $PWD`')\n" +
                                "    ws {\n" + // and this locks a second one
                                "        sh('echo before=`basename $PWD`')\n" +
View Full Code Here

        assertEquals(null, b1.getPreviousBuild());
    }

    @Test public void parameters() throws Exception {
        p.setDefinition(new CpsFlowDefinition("node {sh('echo param=' + PARAM)}"));
        p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("PARAM", null)));
        WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("PARAM", "value"))));
        r.assertLogContains("param=value", b);
    }
View Full Code Here

    }

    @Test public void parameters() throws Exception {
        WorkflowJob us = j.jenkins.createProject(WorkflowJob.class, "us");
        FreeStyleProject ds = j.jenkins.createProject(FreeStyleProject.class, "ds");
        ds.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("branch", "master"), new BooleanParameterDefinition("extra", false, null)));
        ds.getBuildersList().add(new Shell("echo branch=$branch extra=$extra"));
        us.setDefinition(new CpsFlowDefinition("build 'ds'"));
        WorkflowRun us1 = j.assertBuildStatusSuccess(us.scheduleBuild2(0));
        FreeStyleBuild ds1 = ds.getBuildByNumber(1);
        j.assertLogContains("branch=master extra=false", ds1);
View Full Code Here

  public ParametersAction getPropagatedAction(
      MasterBuild masterBuild,
      AbstractProject subProject,
      ParametersAction action) {
    ParametersDefinitionProperty pdp = (ParametersDefinitionProperty)
        subProject.getProperty(ParametersDefinitionProperty.class);
    if (pdp == null) {
        return null; // This project does not have parameters
    }

    List<ParameterValue> values = Lists.<ParameterValue>newArrayList();
    for (ParameterValue value : action.getParameters()) {
      String name = value.getName();
      ParameterDefinition pd = pdp.getParameterDefinition(name);
      if (pd == null) {
        continue; // This project does not have this parameter
      }

      // File parameters are special
View Full Code Here

              spjp.getDefaultSubProjectsString()));
    }

    ParametersAction a = null;
    if (!parameters.isEmpty()) {
      ParametersDefinitionProperty pdp =
          job.getProperty(ParametersDefinitionProperty.class);
      if (pdp == null) {
        throw new AbortException(
            String.format(
                "%s is not parameterized but the -p option was specified.",
                job.getDisplayName()));
      }

      List<ParameterValue> values = Lists.<ParameterValue>newArrayList();

      for (Map.Entry<String, String> e : parameters.entrySet()) {
        String name = e.getKey();
        ParameterDefinition pd = pdp.getParameterDefinition(name);
        if (pd == null) {
          throw new AbortException(
              String.format(
                  "\'%s\' is not a valid parameter. Did you mean %s?",
                  name,
                  EditDistance.findNearest(
                      name,
                      pdp.getParameterDefinitionNames())));
         }
         values.add(pd.createValue(this, e.getValue()));
       }

       // handle missing parameters by adding as default values ISSUE JENKINS-7162
       for (ParameterDefinition pd :  pdp.getParameterDefinitions()) {
         if (parameters.containsKey(pd.getName()))
           continue;

         // not passed in use default
         values.add(pd.getDefaultParameterValue());
View Full Code Here

    }

    private static Map<String, ParameterDefinition> getParameterDefinitionsMap(AbstractProject<?,?> project) {
        HashMap<String, ParameterDefinition> m = new HashMap<String, ParameterDefinition>();

        ParametersDefinitionProperty property = project.getProperty(ParametersDefinitionProperty.class);

        if (property != null) {
            for (ParameterDefinition pd : property.getParameterDefinitions()) {
                m.put(pd.getName(), pd);
            }
        }

        return m;
View Full Code Here

    public ParametersAction transformParametersAction(ParametersAction a, AbstractProject<?,?> project) {
        return ParameterizedTriggerUtils.mergeParameters(getDefaultParameters(project), (ParametersAction)a);
    }

    private static ParametersAction getDefaultParameters(AbstractProject<?,?> project) {
        ParametersDefinitionProperty property = project.getProperty(ParametersDefinitionProperty.class);

        if (property == null) {
            return new ParametersAction();
        }

        List<ParameterValue> parameters = new ArrayList<ParameterValue>();
        for (ParameterDefinition pd : property.getParameterDefinitions()) {
            ParameterValue param = pd.getDefaultParameterValue();
            if (param != null) {
                parameters.add(param);
            }
        }
View Full Code Here

        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);
    }
View Full Code Here

TOP

Related Classes of hudson.model.ParametersDefinitionProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.