Package hudson.model

Examples of hudson.model.ParametersAction


        list.add(script.getRemote());

        //Add script parameters
        if(scriptParameters != null && !scriptParameters.isEmpty()) {
            String[] params = parseParams(scriptParameters);
            ParametersAction parameters = build.getAction(ParametersAction.class);
            for(String param : params) {
              //first replace parameter from parameterized build
              if (parameters != null) {
                    param = parameters.substitute(build, param);
                }
              //then replace evn vars
              param = Util.replaceMacro(param,vr);
                list.add(param);
            }
View Full Code Here


                                "        sh('echo after=`basename $PWD`')\n" +
                                "    }\n" +
                                "}"
                ));
                p.save();
                WorkflowRun b1 = p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("FLAG", "one"))).waitForStart();
                CpsFlowExecution e1 = (CpsFlowExecution) b1.getExecutionPromise().get();
                while (watchDescriptor.getActiveWatches().isEmpty()) {
                    assertTrue(JenkinsRule.getLog(b1), b1.isBuilding());
                    waitForWorkflowToSuspend(e1);
                }
                WorkflowRun b2 = p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("FLAG", "two"))).waitForStart();
                CpsFlowExecution e2 = (CpsFlowExecution) b2.getExecutionPromise().get();
                while (watchDescriptor.getActiveWatches().size() == 1) {
                    assertTrue(JenkinsRule.getLog(b2), b2.isBuilding());
                    waitForWorkflowToSuspend(e2);
                }
            }
        });
        story.addStep(new Statement() {
            @Override public void evaluate() throws Throwable {
                rebuildContext(story.j);
                WorkflowRun b1 = p.getBuildByNumber(1);
                CpsFlowExecution e1 = (CpsFlowExecution) b1.getExecution();
                assertThatWorkflowIsSuspended(b1, e1);
                WorkflowRun b2 = p.getBuildByNumber(2);
                CpsFlowExecution e2 = (CpsFlowExecution) b2.getExecution();
                assertThatWorkflowIsSuspended(b2, e2);
                FileUtils.write(new File(jenkins().getRootDir(), "one"), "here");
                FileUtils.write(new File(jenkins().getRootDir(), "two"), "here");
                story.j.waitUntilNoActivity();
                assertBuildCompletedSuccessfully(b1);
                assertBuildCompletedSuccessfully(b2);
                story.j.assertLogContains("default=demo", b1);
                story.j.assertLogContains("before=demo@2", b1);
                story.j.assertLogContains("after=demo@2", b1);
                story.j.assertLogContains("default=demo@3", b2);
                story.j.assertLogContains("before=demo@4", b2);
                story.j.assertLogContains("after=demo@4", b2);
                FileUtils.write(new File(jenkins().getRootDir(), "three"), "here");
                WorkflowRun b3 = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("FLAG", "three"))));
                story.j.assertLogContains("default=demo", b3);
                story.j.assertLogContains("before=demo@2", b3);
                story.j.assertLogContains("after=demo@2", b3);
            }
        });
View Full Code Here

        List<Action> actions = new ArrayList<Action>();
        actions.add(new BuildTriggerAction(getContext()));
        actions.add(new CauseAction(new Cause.UpstreamCause(invokingRun)));
        List<ParameterValue> parameters = step.getParameters();
        if (parameters != null) {
            actions.add(new ParametersAction(parameters));
        }
        new ParameterizedJobMixIn() {
            @Override protected Job asJob() {
                return (Job) project;
            }
View Full Code Here

    }

    @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

        getBinding().setVariable(STEPS_VAR, new DSL(owner));
        Queue.Executable qe = owner.getExecutable();
        if (qe instanceof Run) {
            EnvVars paramEnv = new EnvVars();
            Run<?,?> run = (Run) qe;
            ParametersAction a = run.getAction(ParametersAction.class);
            if (a != null) {
                for (ParameterValue v : a) {
                    v.buildEnvironment(run, paramEnv);
                }
            }
View Full Code Here

    List<ParametersAction> parametersActionList =
        masterBuild.getActions(ParametersAction.class);
    List<ParametersAction> propagatedParametersActionList =
        Lists.<ParametersAction>newArrayList();
    for (ParametersAction action : parametersActionList) {
      ParametersAction propagated =
          getPropagatedAction(masterBuild, subProject, action);
      propagatedParametersActionList.add(propagated);
    }

    return propagatedParametersActionList.toArray(
View Full Code Here

            location, file, originalFileName);
      }
      values.add(value);
    }

    return new ParametersAction(values);
  }
View Full Code Here

          String.format(
              "Executing DEFAULT sub-jobs: %s",
              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());
       }

       a = new ParametersAction(values);
     }

     String user = Hudson.getAuthentication().getName();

     CLICause cause = new CLICause(user, a, sp);
View Full Code Here

    }

    List<Action> getBaseActions(Collection<AbstractBuildParameters> configs, AbstractBuild<?,?> build, TaskListener listener)
            throws IOException, InterruptedException, DontTriggerException {
    List<Action> actions = new ArrayList<Action>();
    ParametersAction params = null;
    for (AbstractBuildParameters config : configs) {
      Action a = config.getAction(build, listener);
      if (a instanceof ParametersAction) {
        params = params == null ? (ParametersAction)a
          : ParameterizedTriggerUtils.mergeParameters(params, (ParametersAction)a);
View Full Code Here

        this.transforms = new ArrayList<ITransformProjectParametersAction>(Arrays.asList(transforms));
    }

    public final List<Action> getProjectSpecificBuildActions(List<Action> baseActions, AbstractProject<?,?> project) {
        List<Action> actions = new ArrayList<Action>();
        ParametersAction pa = getParametersAction(baseActions);

        // Copy everything except the ParametersAction
        for (Action a : baseActions) {
            if (! (a instanceof ParametersAction)) {
                actions.add(a);
View Full Code Here

TOP

Related Classes of hudson.model.ParametersAction

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.