@Test public void customWorkspaceUsingPathParameter() throws Exception { WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, RandomStringUtils.randomAlphanumeric(7)); job.setDefinition(new CpsFlowDefinition(format("" + "def customPath = \"${env.JOB_NAME}/${PR_BUILD_NUMBER}/${env.BUILD_NUMBER}\" \n" + "def extWorkspace = exwsAllocate diskPoolId: '%s', path: customPath \n" + "node { \n" + " exws (extWorkspace) { \n" + " writeFile file: 'foobar.txt', text: 'foobar' \n" + " } \n" + "} \n", DISK_POOL_ID))); String prBuildNumberValue = "22"; ParameterValue parameterValue = new StringParameterValue("PR_BUILD_NUMBER", prBuildNumberValue); ParametersAction parameterValues = new ParametersAction(parameterValue); WorkflowRun run = j.assertBuildStatusSuccess(job.scheduleBuild2(0, parameterValues)); verifyWorkspacePath(format("%s/%s/%d", job.getFullName(), prBuildNumberValue, run.getNumber()), run); }
/** * Constructs the environment variables for the current build. * * @return the current build environment variables * @throws IOException * @throws InterruptedException */ private EnvVars constructEnvVars() throws IOException, InterruptedException { EnvVars envVars = build.getEnvironment(listener); if (build instanceof AbstractBuild) { envVars.putAll(((AbstractBuild<?, ?>) build).getBuildVariables()); // Add in matrix axes.. } else { // Abstract#getEnvironment(TaskListener) put build parameters to // environments, but Run#getEnvironment(TaskListener) doesn't. // That means we can't retrieve build parameters from WorkflowRun // as it is a subclass of Run, not of AbstractBuild. // We need expand build parameters manually. // See JENKINS-26694, JENKINS-30357 for details. for (ParametersAction pa : build.getActions(ParametersAction.class)) { // We have to extract parameters manually as ParametersAction#buildEnvVars // (overrides EnvironmentContributingAction#buildEnvVars) // is applicable only for AbstractBuild. for (ParameterValue pv : pa.getParameters()) { pv.buildEnvironment(build, envVars); } } } return envVars; }
public static List<Action> setJobRunParamsFromEnvAndUIParams(WorkflowJob job, JenkinsPipelineBuildStrategy strat, List<Action> buildActions, ParametersAction params) { List<EnvVar> envs = strat.getEnv(); List<ParameterValue> envVarList = new ArrayList<ParameterValue>(); if (envs.size() > 0) { // build list of env var keys for compare with existing job params for (EnvVar env : envs) { envVarList.add(new StringParameterValue(env.getName(), env.getValue())); } } if (params != null) envVarList.addAll(params.getParameters()); if (envVarList.size() > 0) buildActions.add(new ParametersAction(envVarList)); return buildActions; }
@Override public ParameterValue createValue(StaplerRequest req) { String[] value = req.getParameterValues(getName()); if (value == null) { return getDefaultParameterValue(); } else if (value.length != 1) { throw new IllegalArgumentException(String.format( "Illegal number of parameter values for %s: %d", getName(), value.length)); } else { List<String> choices = getChoices(); if (choices.contains(value[0])) { return new StringParameterValue(getName(), value[0], getDescription()); } else { throw new IllegalArgumentException(String.format( "Value %s for parameter %s is not a valid choice.", value[0], getName())); } } }
public static Map<String, Object> getBuildParameters(Run build) { List<ParametersAction> actions = build.getActions(ParametersAction.class); if (actions != null) { Map<String, Object> answer = new HashMap<String, Object>(); for (ParametersAction action : actions) { List<ParameterValue> parameters = action.getParameters(); if (parameters != null) { for (ParameterValue parameter : parameters) { String name = parameter.getName(); Object value = parameter.getValue(); answer.put(name, value); } } } return answer; } return null; }
public static Object buildParameterOrNull(TaskListener listener, FlowExecution flowExecution, String parameter, String defaultValue) throws IOException { if (Strings.isNullOrBlank(parameter)) { log(listener, "No parameter name!"); } else { Run<?, ?> run = $build(flowExecution); ParametersAction action = null; if (run != null) { action = run.getAction(ParametersAction.class); } else { log(listener, "No $build could be found from flowExecution " + flowExecution); } if (action == null) { log(listener, "No ParametersAction could be found!"); } else { ParameterValue parameterValue = action.getParameter(parameter); if (parameterValue == null) { log(listener, "No ParameterValue could be found for '" + parameter + "'"); } else { return parameterValue.getValue(); } } } return defaultValue; }
@Override public Set<ParameterValue> getRunParameters() { Set<ParameterValue> parameters = new HashSet<ParameterValue>(); parameters.add(new StringParameterValue(KEY_REPO_NAME, getRepoName())); String host = getRegistryHost(); if (!StringUtils.isBlank(host)) { parameters.add(new StringParameterValue(KEY_DOCKER_HUB_HOST, host)); } String tag = getTag(); if (!StringUtils.isBlank(tag)) { parameters.add(new StringParameterValue(KEY_TAG, tag)); } String pusher = getPusher(); if (!StringUtils.isBlank(pusher)) { parameters.add(new StringParameterValue(KEY_PUSHER, pusher)); } return parameters; }
/** * @see jenkins.model.ParameterizedJobMixIn#getDefaultParametersValues() */ public static List<ParameterValue> getDefaultParametersValues(Job<?, ?> job) { ParametersDefinitionProperty paramDefProp = job.getProperty(ParametersDefinitionProperty.class); List<ParameterValue> defValues = new ArrayList<>(); /* * This check is made ONLY if someone will call this method even if isParametrized() is false. */ if (paramDefProp == null) { return defValues; } /* Scan for all parameter with an associated default values */ for (ParameterDefinition paramDefinition : paramDefProp.getParameterDefinitions()) { ParameterValue defaultValue = paramDefinition.getDefaultParameterValue(); if (defaultValue != null) { defValues.add(defaultValue); } } return defValues; }
private DeployJobVariables extractDeployJobVariables(AbstractBuild build) { String environment = DeployJobVariablesBuilder.UNDEFINED; String version = DeployJobVariablesBuilder.UNDEFINED; List<ParametersAction> actionList = Util.filter(build.getAllActions(), ParametersAction.class); for (ParametersAction parametersAction : actionList) { List<ParameterValue> params = parametersAction.getParameters(); for (ParameterValue parameterValue : params) { if (DashboardView.PARAM_ENVIRONMENT.equalsIgnoreCase((String) parameterValue.getName())) { environment = (String) parameterValue.getValue(); } if (DashboardView.PARAM_VERSION.equalsIgnoreCase((String) parameterValue.getName())) { version = (String) parameterValue.getValue(); } } } return DeployJobVariablesBuilder.createBuilder().version(version).environment(environment).build(); }
/** * this method started out as hudson.model.AbstractProject.getDefaultParametersValues() * @param parameterValues * @return the ParameterValues as set from the crontab row or their defaults */ @SuppressWarnings("unchecked") private List<ParameterValue> configurePropertyValues(Map<String, String> parameterValues) { assert job != null : "job must not be null if this was 'started'"; ParametersDefinitionProperty paramDefProp = (ParametersDefinitionProperty) job .getProperty(ParametersDefinitionProperty.class); ArrayList<ParameterValue> defValues = new ArrayList<ParameterValue>(); /* Scan for all parameter with an associated default values */ for (ParameterDefinition paramDefinition : paramDefProp.getParameterDefinitions()) { ParameterValue defaultValue = paramDefinition.getDefaultParameterValue(); if (parameterValues.containsKey(paramDefinition.getName())) { ParameterizedStaplerRequest request = new ParameterizedStaplerRequest( parameterValues.get(paramDefinition.getName())); defValues.add(paramDefinition.createValue(request)); } else if (defaultValue != null) defValues.add(defaultValue); } return defValues; }
/** Get the default parameter values for the given delegate */ private ParametersAction getDefaultParametersValues( AbstractProject delegate) { final ParametersDefinitionProperty property = (ParametersDefinitionProperty) delegate.getProperty( ParametersDefinitionProperty.class); if (property == null) { return null; } final List<ParameterValue> result = Lists.newArrayList(); for (ParameterDefinition def : property.getParameterDefinitions()) { ParameterValue value = def.getDefaultParameterValue(); if (value != null) { result.add(value); } } return new ParametersAction(result); }
/** * Find the previous BuildData for the given pull request number; this may return null */ private BuildData findPreviousBuildForPullId(StringParameterValue pullIdPv) { // find the previous build for this particular pull requet, it may not be the last build for (Run<?,?> r : job.getBuilds()) { ParametersAction pa = r.getAction(ParametersAction.class); if (pa != null) { for (ParameterValue pv : pa.getParameters()) { if (pv.equals(pullIdPv)) { for (BuildData bd : r.getActions(BuildData.class)) { return bd; } } } } } return null; }
/** * It extracts and removes internal parameters from the full list of parameters as they need to be managed * in a special way for security reasons (related to SECURITY-170). * * @param values internal parameters values (internal parameters are defined in {@link #getParameterDefinitions()} * @return internal parameters values */ private List<ParameterValue> extractAndRemoveInternalParameters(List<ParameterValue> values) { List<ParameterValue> internal = new ArrayList<ParameterValue>(); List<ParameterDefinition> parameterDefinitions = getParameterDefinitions(); Iterator<ParameterValue> it = values.iterator(); while (it.hasNext()) { ParameterValue next = it.next(); for (ParameterDefinition pd : parameterDefinitions) { if (next.getName().equals(pd.getName())) { internal.add(next); it.remove(); break; } } } return internal; }
@Test public void testCreateValue() { GroovyScript script = new GroovyScript(new SecureGroovyScript(SCRIPT, Boolean.FALSE, null), new SecureGroovyScript(FALLBACK_SCRIPT, Boolean.FALSE, null)); ChoiceParameter param = new ChoiceParameter("name", "description", "some-random-name", script, "choiceType", true, 0); ParameterValue value = param.createValue("value"); assertEquals("value", value.getValue().toString()); JSONObject json = new JSONObject(); json.put("name", "name"); json.put("value", "value"); StaplerRequest request = PowerMockito.mock(StaplerRequest.class); PowerMockito.when(request.bindJSON(StringParameterValue.class, json)).thenReturn((StringParameterValue) value); value = param.createValue(request, json); assertEquals("value", value.getValue().toString()); }
private List<ParameterValue> getParametersValues(final Job job, final String branch) { final ParametersDefinitionProperty paramDefProp = (ParametersDefinitionProperty) job.getProperty(ParametersDefinitionProperty.class); final ArrayList<ParameterValue> defValues = new ArrayList<>(); for (final ParameterDefinition paramDefinition : paramDefProp.getParameterDefinitions()) { if ("BRANCH".equals(paramDefinition.getName())) { final StringParameterValue branchParam = new StringParameterValue("BRANCH", branch); defValues.add(branchParam); } else { final ParameterValue defaultValue = paramDefinition.getDefaultParameterValue(); if (defaultValue != null) defValues.add(defaultValue); } } return defValues; }
/** * This method dumps the default values of all parameters (even derived * ones) into an XML file. * <p> * Do note that this does not do any expansion, * it merely outputs the last default value defined for the given * parameter. If you want the full expansion, call * {@link #doGetParamExpansionsAsXML()} * * @return raw XML string */ public String doGetParamDefaultsAsXML() { Object obj = onInheritChangeBuffer.get(this, "doGetParamDefaultsAsXML"); if (obj != null && obj instanceof String) { return (String) obj; } //Fetching a list of unique parameters List<ParameterDefinition> defLst = this.getParameters(IMode.INHERIT_FORCED); LinkedList<ParameterValue> valLst = new LinkedList<ParameterValue>(); //Then, we fetch the expansion of these based on their defaults for (ParameterDefinition pd : defLst) { ParameterValue pv = pd.getDefaultParameterValue(); if (pv != null) { valLst.add(pv); } } String str = Jenkins.XSTREAM2.toXML(valLst); onInheritChangeBuffer.set(this, "doGetParamDefaultsAsXML", str); return str; }
@Override public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue) { if (!(defaultValue instanceof StringParameterValue)) { //This should never happen return super.copyWithDefaultValue(defaultValue); } StringParameterValue spv = ((StringParameterValue) defaultValue); String value = spv.value; InheritableStringParameterReferenceDefinition isprd = new InheritableStringParameterReferenceDefinition( this.getName(), value ); isprd.setRootProperty(this.getRootProperty()); return isprd; }
/** * This function is invoked, when the user creates the value from an HTML * form request. This happens, for example, when a build is triggered * through the GUI instead of through the CLI. * <p> * This function is what makes an inheritable parameter inheritable at all. * Here, the value entered by the user is combined with the values of its * parents. This may mean: * <ul> * <li>overwriting the parent's value,</li> * <li>ensuring that a particular value is correctly set (if mandatory), * <li>that it does not overwrite a fixed value or</li> * <li>appending the parameter to its parent.</li> * </ul> * A complicating fact is that by default, a {@link ParameterDefinition} * is not informed for what kind of job is is being used, as that is not * a necessary piece of information in Vanilla-Jenkins. * * @see {@link #baseProject}. */ @Override public ParameterValue createValue(StaplerRequest req, JSONObject jo) { //First, we produce a temporary SPV from the JSON request StringParameterValue value = req.bindJSON( StringParameterValue.class, jo ); if (value == null) { //No such parameter name at all return null; } //Then, we check if we can get a properly derived value try { StringParameterValue dValue = this.produceDerivedValue(value.value); //Checking if that worked if (dValue == null) { return value; } else { return dValue; } } catch (IllegalArgumentException ex) { log.warning("Could not create inheritable string parameter: " + ex.toString()); return value; } }
public static final void mergeParameters(List<Action> actions) { List<ParameterValue> pv = new LinkedList<ParameterValue>(); Iterator<Action> iter = actions.iterator(); while (iter.hasNext()) { Action a = iter.next(); if (!(a instanceof ParametersAction)) { continue; } ParametersAction pa = (ParametersAction) a; pv.addAll(pa.getParameters()); iter.remove(); } if (!pv.isEmpty()) { actions.add(new ParametersAction(pv)); } }
public static Map<String, String> getResolvedBuildParameters( InheritanceProject project ) { Map<String, String> result = new HashMap<String, String>(); List<ParameterDefinition> parameters = project.getParameters( IMode.INHERIT_FORCED ); for (ParameterDefinition pDef : parameters) { ParameterValue pVal = pDef.getDefaultParameterValue(); if (pVal instanceof StringParameterValue) { result.put( pDef.getName(), ((StringParameterValue) pVal).value ); } } //We do not resolve parameters; as they are most likely not complete anyway return result; }
public InheritanceBuild buildAndAssertValue(XmlProject p, String param, String value, boolean assertSuccess) throws IOException { try { InheritanceBuild build = (assertSuccess) ? jRule.buildAndAssertSuccess(p.project) : p.project.scheduleBuild2(0).get(); Assert.assertNotNull(build); ParametersAction pa = build.getAction(ParametersAction.class); Assert.assertNotNull("Build has no parameters", pa); ParameterValue pv = pa.getParameter(param); Assert.assertNotNull("Build has no parameter P", pv); Assert.assertTrue("Parameter is not a StringParameterValue", pv instanceof StringParameterValue); Assert.assertEquals("Parameter does not have correct value", value, ((StringParameterValue)pv).value); return build; } catch (Exception e) { throw new IOException(e); } }
@Override public ParameterValue createValue(StaplerRequest arg0, JSONObject jsonObj) { Object value = jsonObj.get("value"); String strValue = ""; if (value instanceof String) { strValue = (String) value; } else if (value instanceof JSONArray) { JSONArray jsonValues = (JSONArray) value; for (int i = 0; i < jsonValues.size(); i++) { strValue += jsonValues.getString(i); if (i < jsonValues.size() - 1) { strValue += ","; } } } if ("".equals(strValue)) { strValue = getDefaultValue(); } GitParameterValue gitParameterValue = new GitParameterValue( jsonObj.getString("name"), strValue); return gitParameterValue; }
private void populatePromotionParameters(List<String> params, Object promotionObj) { final Promotion promotion = (Promotion) promotionObj; for (ParameterValue value : promotion.getParameterValues()) { if (value instanceof StringParameterValue) { if (StringUtils.isNotBlank(((StringParameterValue) value).value)) { params.add("<strong>" + value.getName() + "</strong>: " + ((StringParameterValue) value).value); } } else if (value instanceof FileParameterValue) { params.add("<strong>" + value.getName() + "</strong>: " + ((FileParameterValue) value).getLocation()); } else if (value instanceof BooleanParameterValue) { if (((BooleanParameterValue) value).value) { params.add("<strong>" + value.getName() + "</strong>: " + Boolean.toString(((BooleanParameterValue) value).value)); } } // TODO: there are more types } }
/** * {@inheritDoc} */ @Override public boolean isSelectable(@Nonnull Run<?,?> run, @Nonnull RunSelectorContext context) { EnvVars otherEnv; try { otherEnv = run.getEnvironment(TaskListener.NULL); } catch (Exception ex) { return false; } if(!(run instanceof AbstractBuild)) { // Abstract#getEnvironment(TaskListener) put build parameters to // environments, but Run#getEnvironment(TaskListener) doesn't. // That means we can't retrieve build parameters from WorkflowRun // as it is a subclass of Run, not of AbstractBuild. // We need expand build parameters manually. // See JENKINS-26694 for details. for(ParametersAction pa: run.getActions(ParametersAction.class)) { // We have to extract parameters manally as ParametersAction#buildEnvVars // (overrides EnvironmentContributingAction#buildEnvVars) // is applicable only for AbstractBuild. for(ParameterValue pv: pa.getParameters()) { pv.buildEnvironment(run, otherEnv); } } } List<StringParameterValue> filters = getFilterParameters(context); for (StringParameterValue spv : filters) { if (!spv.value.equals(otherEnv.get(spv.getName()))) { context.logDebug( "{0}: {1} is declined", getDisplayName(), run.getDisplayName() ); return false; } } return true; }
private static ParametersAction dumpParams(List<Action> actions) { for (Action action : actions) { if (action instanceof ParametersAction) { ParametersAction paramAction = (ParametersAction) action; if (LOGGER.isLoggable(Level.FINE)) for (ParameterValue param : paramAction.getAllParameters()) { LOGGER.fine("param name " + param.getName() + " param value " + param.getValue()); } return paramAction; } } return null; }
@Override public ParameterValue createValue(StaplerRequest req, JSONObject jo) { JSONArray jsonArray = (JSONArray)jo.get("value"); List<String> choices = getChoices(); List<String> selectionList = new ArrayList<>(); for(int i=0;i<choices.size();i++){ String choice = choices.get(i); if((Boolean)jsonArray.get(i)){ selectionList.add(choice); } } String selections = StringUtils.join(selectionList, ','); StringParameterValue value = new StringParameterValue(getName(), selections, getDescription()); return value; }
@Override // @Deprecated ??? public ParameterValue createValue(StaplerRequest req) { String[] value = req.getParameterValues(getName()); String selections = StringUtils.join(value, ','); return new StringParameterValue(getName(), selections, getDescription()); }
protected ParameterValue createValue() { // Runs the DSL and gets its result Object any = runDSL(); // Gets the value for this object String value = any != null ? getProperty(any, getValueProperty()) : ""; // Returns the string as a parameter return new StringParameterValue(getName(), value, getDescription()); }
@Test public void dsl_returning_null_gives_an_empty_parameter() { OntrackSingleParameterDefinition definition = new OntrackSingleParameterDefinition( "NAME", "My parameter", "", true, "name", new MockDSLRunner(null) ); ParameterValue parameterValue = definition.createValue(); assertEquals("NAME", parameterValue.getName()); assertEquals("", parameterValue.getValue()); }
@VisibleForTesting static String getAbortOnRevisionId(AbstractBuild build) { ParametersAction parameters = build.getAction(ParametersAction.class); if (parameters != null) { ParameterValue parameterValue = parameters.getParameter( PhabricatorPlugin.ABORT_ON_REVISION_ID_FIELD); if (parameterValue != null) { return (String) parameterValue.getValue(); } } return null; }
/** * Provide parameters to be put into a build. * @return the parameters * @deprecated misspelled and wrong context naming. Use {@link #getRunParameters()} */ @Deprecated public Set<ParameterValue> getJobParamerers() { if (Util.isOverridden(PushNotification.class, getClass(), "getRunParameters")) { return getRunParameters(); } return Collections.emptySet(); }
@Override public Set<ParameterValue> getRunParameters() { Set<ParameterValue> parameters = new HashSet<ParameterValue>(); parameters.add(new StringParameterValue(KEY_REPO_NAME, getRepoName())); String host = getRegistryHost(); if (!StringUtils.isBlank(host)) { parameters.add(new StringParameterValue(KEY_DOCKER_REGISTRY_HOST, host)); } return parameters; }
@Override public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException { WebHookCause cause = (WebHookCause)r.getCause(WebHookCause.class); if (cause != null) { Set<ParameterValue> parameters = cause.getPushNotification().getRunParameters(); for (ParameterValue parameter : parameters) { parameter.buildEnvironment(r, envs); } } }
public static QueueTaskFuture schedule(Job<?, ?> job, int number, String param, int queuetPeriod) { ParameterizedJobMixIn jobMixIn = JobInfoHelpers.asParameterizedJobMixIn(job); GitHubPRCause cause = newGitHubPRCause().withNumber(number); ParametersAction parametersAction = new ParametersAction( Collections.<ParameterValue>singletonList(new StringParameterValue("value", param)) ); return jobMixIn.scheduleBuild2(queuetPeriod, new CauseAction(cause), parametersAction); }
public QueueTaskFuture<?> startJob(GhprcCause cause, GhprcRepository repo) { ArrayList<ParameterValue> values = getDefaultParameters(); final String commitSha = cause.isMerged() ? "origin/pr/" + cause.getPullID() + "/merge" : cause.getCommit(); values.add(new StringParameterValue("sha1", commitSha)); values.add(new StringParameterValue("ghprcActualCommit", cause.getCommit())); setCommitAuthor(cause, values); final StringParameterValue pullIdPv = new StringParameterValue("ghprcPullId", String.valueOf(cause.getPullID())); values.add(pullIdPv); values.add(new StringParameterValue("ghprcTargetBranch", String.valueOf(cause.getTargetBranch()))); values.add(new StringParameterValue("ghprcSourceBranch", String.valueOf(cause.getSourceBranch()))); values.add(new StringParameterValue("GIT_BRANCH", String.valueOf(cause.getSourceBranch()))); // it's possible the GHUser doesn't have an associated email address values.add(new StringParameterValue("ghprcPullAuthorEmail", getString(cause.getAuthorEmail(), ""))); values.add(new StringParameterValue("ghprcPullDescription", String.valueOf(cause.getShortDescription()))); values.add(new StringParameterValue("ghprcPullTitle", String.valueOf(cause.getTitle()))); values.add(new StringParameterValue("ghprcPullLink", String.valueOf(cause.getUrl()))); values.add(new StringParameterValue("ghprcOutputFile", getDescriptor().getOutputFile())); try { values.add(new StringParameterValue("ghprcTargetCommit", repo.getGitHubRepo().getBranches().get(cause.getTargetBranch()).getSHA1())); } catch (IOException e) { logger.log(Level.SEVERE, "Unable to get branches from github repo", e); } // add the previous pr BuildData as an action so that the correct change log is generated by the GitSCM plugin // note that this will be removed from the Actions list after the job is completed so that the old (and incorrect) // one isn't there return this.job.scheduleBuild2(job.getQuietPeriod(), cause, new ParametersAction(values), findPreviousBuildForPullId(pullIdPv)); }
private void setCommitAuthor(GhprcCause cause, ArrayList<ParameterValue> values) { String authorName = ""; String authorEmail = ""; if (cause.getCommitAuthor() != null) { authorName = getString(cause.getCommitAuthor().getName(), ""); authorEmail = getString(cause.getCommitAuthor().getEmail(), ""); } values.add(new StringParameterValue("ghprcActualCommitAuthor", authorName)); values.add(new StringParameterValue("ghprcActualCommitAuthorEmail", authorEmail)); }
/** * Find the previous BuildData for the given pull request number; this may return null */ private BuildData findPreviousBuildForPullId(StringParameterValue pullIdPv) { // find the previous build for this particular pull request, it may not be the last build for (Run<?, ?> r : job.getBuilds()) { ParametersAction pa = r.getAction(ParametersAction.class); if (pa != null) { for (ParameterValue pv : pa.getParameters()) { if (pv.equals(pullIdPv)) { Iterables.getFirst(r.getActions(BuildData.class), null); } } } } return null; }
private ArrayList<ParameterValue> getDefaultParameters() { ArrayList<ParameterValue> values = new ArrayList<ParameterValue>(); ParametersDefinitionProperty pdp = this.job.getProperty(ParametersDefinitionProperty.class); if (pdp != null) { for (ParameterDefinition pd : pdp.getParameterDefinitions()) { if (pd.getName().equals("sha1")) continue; values.add(pd.getDefaultParameterValue()); } } return values; }
private static ParameterValue getBooleanParam(JSONObject formData, String paramName) { JSONObject paramObj = JSONObject.fromObject(formData.get(paramName)); String name = paramObj.getString("name"); FlakyTestResultAction.logger.log(Level.FINE, "Param: " + name + " with value: " + paramObj.getBoolean("value")); return new BooleanParameterValue(name, paramObj.getBoolean("value")); }
private static ParameterValue getStringParam(JSONObject formData, String paramName) { JSONObject paramObj = JSONObject.fromObject(formData.get(paramName)); String name = paramObj.getString("name"); FlakyTestResultAction.logger.log(Level.FINE, "Param: " + name + " with value: " + paramObj.getString("value")); return new StringParameterValue(name, paramObj.getString("value")); }