当前位置: 首页>>代码示例>>Java>>正文


Java ParameterValue类代码示例

本文整理汇总了Java中hudson.model.ParameterValue的典型用法代码示例。如果您正苦于以下问题:Java ParameterValue类的具体用法?Java ParameterValue怎么用?Java ParameterValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParameterValue类属于hudson.model包,在下文中一共展示了ParameterValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDefaultParametersValues

import hudson.model.ParameterValue; //导入依赖的package包/类
/**
 * @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;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:26,代码来源:JobHelper.java

示例2: getParametersValues

import hudson.model.ParameterValue; //导入依赖的package包/类
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;
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:18,代码来源:GithubWebhook.java

示例3: customWorkspaceUsingPathParameter

import hudson.model.ParameterValue; //导入依赖的package包/类
@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);
}
 
开发者ID:jenkinsci,项目名称:external-workspace-manager-plugin,代码行数:20,代码来源:CustomWorkspaceTest.java

示例4: constructEnvVars

import hudson.model.ParameterValue; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:31,代码来源:RunSelectorContext.java

示例5: setJobRunParamsFromEnvAndUIParams

import hudson.model.ParameterValue; //导入依赖的package包/类
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;
}
 
开发者ID:jenkinsci,项目名称:openshift-sync-plugin,代码行数:20,代码来源:JenkinsUtils.java

示例6: createValue

import hudson.model.ParameterValue; //导入依赖的package包/类
@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()));
        }
    }
}
 
开发者ID:jenkinsci,项目名称:ontrack-plugin,代码行数:23,代码来源:OntrackChoiceParameterDefinition.java

示例7: getBuildParameters

import hudson.model.ParameterValue; //导入依赖的package包/类
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;
}
 
开发者ID:fabric8io,项目名称:fabric8-jenkins-workflow-steps,代码行数:19,代码来源:Runs.java

示例8: buildParameterOrNull

import hudson.model.ParameterValue; //导入依赖的package包/类
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;
}
 
开发者ID:fabric8io,项目名称:fabric8-jenkins-workflow-steps,代码行数:25,代码来源:Steps.java

示例9: getRunParameters

import hudson.model.ParameterValue; //导入依赖的package包/类
@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;
}
 
开发者ID:jenkinsci,项目名称:dockerhub-notification-plugin,代码行数:19,代码来源:DockerHubPushNotification.java

示例10: extractDeployJobVariables

import hudson.model.ParameterValue; //导入依赖的package包/类
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();
}
 
开发者ID:codecentric,项目名称:jenkins-deployment-dashboard-plugin,代码行数:18,代码来源:EnvironmentTagBuilder.java

示例11: configurePropertyValues

import hudson.model.ParameterValue; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:jwmach1,项目名称:parameterized-scheduler,代码行数:27,代码来源:ParameterizedTimerTrigger.java

示例12: getDefaultParametersValues

import hudson.model.ParameterValue; //导入依赖的package包/类
/** 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);
}
 
开发者ID:jenkinsci,项目名称:yaml-project-plugin,代码行数:21,代码来源:YamlBuild.java

示例13: findPreviousBuildForPullId

import hudson.model.ParameterValue; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:ds2wang,项目名称:ghprb-copy,代码行数:20,代码来源:GhprbTrigger.java

示例14: extractAndRemoveInternalParameters

import hudson.model.ParameterValue; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:24,代码来源:ReviewAction.java

示例15: testCreateValue

import hudson.model.ParameterValue; //导入依赖的package包/类
@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());
}
 
开发者ID:imoutsatsos,项目名称:uno-choice-plugin,代码行数:22,代码来源:TestAbstractUnoChoiceParameter.java


注:本文中的hudson.model.ParameterValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。