hudson.model.ParameterValue Java Examples
The following examples show how to use
hudson.model.ParameterValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GithubWebhook.java From DotCi with MIT License | 6 votes |
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; }
Example #2
Source File: JobHelper.java From github-integration-plugin with MIT License | 6 votes |
/** * @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 (isNull(paramDefProp)) { 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; }
Example #3
Source File: ParameterizedTimerTrigger.java From parameterized-scheduler with MIT License | 6 votes |
/** * 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; }
Example #4
Source File: EnvironmentTagBuilder.java From jenkins-deployment-dashboard-plugin with MIT License | 6 votes |
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(); }
Example #5
Source File: GitHubSCMSource.java From github-integration-plugin with MIT License | 5 votes |
@Nonnull @Override protected List<Action> retrieveActions(@Nonnull SCMRevision revision, @CheckForNull SCMHeadEvent event, @Nonnull TaskListener listener) throws IOException, InterruptedException { GitHubSCMRevision gitHubSCMRevision = (GitHubSCMRevision) revision; GitHubCause<?> cause = gitHubSCMRevision.getCause(); if (nonNull(cause)) { List<ParameterValue> params = new ArrayList<>(); cause.fillParameters(params); return Arrays.asList(new CauseAction(cause), new GitHubParametersAction(params)); } return Collections.emptyList(); }
Example #6
Source File: DownstreamJobPlugin.java From DotCi with MIT License | 5 votes |
private NoDuplicatesParameterAction getParamsAction(Map<String, String> jobParams) { List<ParameterValue> params = new ArrayList<ParameterValue>(); for (Map.Entry<String, String> entry : jobParams.entrySet()) { params.add(new StringParameterValue(entry.getKey(), entry.getValue())); } return new NoDuplicatesParameterAction(params); }
Example #7
Source File: DownstreamJobPlugin.java From DotCi with MIT License | 5 votes |
private String getSourceBuildNumber(DynamicBuild dynamicBuild) { if (dynamicBuild.getCause() instanceof DotCiUpstreamTriggerCause) { List<ParameterValue> params = dynamicBuild.getAction(ParametersAction.class).getParameters(); for (ParameterValue param : params) { if (param.getName().equals("SOURCE_BUILD")) { return (String) param.getValue(); } } } return "" + dynamicBuild.getNumber(); }
Example #8
Source File: ProcessedBuild.java From DotCi with MIT License | 5 votes |
@Override public List<ParameterValue> getParameters() { if (this.build.getAction(ParametersAction.class) != null) { return this.build.getAction(ParametersAction.class).getParameters(); } return Lists.newArrayList(); }
Example #9
Source File: DeflakeAction.java From flaky-test-handler-plugin with Apache License 2.0 | 5 votes |
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")); }
Example #10
Source File: DeflakeAction.java From flaky-test-handler-plugin with Apache License 2.0 | 5 votes |
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")); }
Example #11
Source File: JobRunnerForCauseTest.java From github-integration-plugin with MIT License | 5 votes |
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); }
Example #12
Source File: BuildBeginInfo.java From qy-wechat-notification-plugin with Apache License 2.0 | 5 votes |
public BuildBeginInfo(String projectName, AbstractBuild<?, ?> build, NotificationConfig config){ //获取请求参数 List<ParametersAction> parameterList = build.getActions(ParametersAction.class); if(parameterList!=null && parameterList.size()>0){ for(ParametersAction p : parameterList){ for(ParameterValue pv : p.getParameters()){ this.params.put(pv.getName(), pv.getValue()); } } } //预计时间 if(build.getProject().getEstimatedDuration()>0){ this.durationTime = build.getProject().getEstimatedDuration(); } //控制台地址 StringBuilder urlBuilder = new StringBuilder(); String jenkinsUrl = NotificationUtil.getJenkinsUrl(); if(StringUtils.isNotEmpty(jenkinsUrl)){ String buildUrl = build.getUrl(); urlBuilder.append(jenkinsUrl); if(!jenkinsUrl.endsWith("/")){ urlBuilder.append("/"); } urlBuilder.append(buildUrl); if(!buildUrl.endsWith("/")){ urlBuilder.append("/"); } urlBuilder.append("console"); } this.consoleUrl = urlBuilder.toString(); //工程名称 this.projectName = projectName; //环境名称 if(config.topicName!=null){ topicName = config.topicName; } }
Example #13
Source File: GitHubEnv.java From github-integration-plugin with MIT License | 5 votes |
static <T extends GitHubCause<?>, X extends Enum<X> & GitHubEnv<T>> void getParams(Class<X> enumClass, T cause, List<ParameterValue> params) { for (GitHubEnv<T> env : enumClass.getEnumConstants()) { env.addParam(cause, params); } }
Example #14
Source File: PhabricatorBuildWrapperTest.java From phabricator-jenkins-plugin with MIT License | 5 votes |
@Test public void getAbortOnRevisionIdIfAvailable() throws Exception { FreeStyleBuild build = buildWithConduit(getFetchDiffResponse(), null, null, true); assertNull(PhabricatorBuildWrapper.getAbortOnRevisionId(build)); List<ParameterValue> parameters = Lists.newArrayList(); parameters.add(new ParameterValue("ABORT_ON_REVISION_ID") { @Override public Object getValue() { return "test"; } }); build.addAction(new ParametersAction(parameters)); assertEquals("test", PhabricatorBuildWrapper.getAbortOnRevisionId(build)); }
Example #15
Source File: ListGitBranchesParameterRebuild.java From list-git-branches-parameter-plugin with MIT License | 5 votes |
@Override public RebuildParameterPage getRebuildPage(ParameterValue parameterValue) { if (parameterValue instanceof ListGitBranchesParameterValue) { return new RebuildParameterPage(parameterValue.getClass(),"value.jelly"); } else { return null; } }
Example #16
Source File: RunContainerImpl.java From blueocean-plugin with MIT License | 5 votes |
/** * Schedules a build. If build already exists in the queue and the pipeline does not * support running multiple builds at the same time, return a reference to the existing * build. * * @return Queue item. */ @Override public BlueRun create(StaplerRequest request) { job.checkPermission(Item.BUILD); if (job instanceof Queue.Task) { ScheduleResult scheduleResult; List<ParameterValue> parameterValues = getParameterValue(request); int expectedBuildNumber = job.getNextBuildNumber(); if(parameterValues.size() > 0) { scheduleResult = Jenkins.getInstance() .getQueue() .schedule2((Queue.Task) job, 0, new ParametersAction(parameterValues), new CauseAction(new Cause.UserIdCause())); }else { scheduleResult = Jenkins.getInstance() .getQueue() .schedule2((Queue.Task) job, 0, new CauseAction(new Cause.UserIdCause())); } // Keep FB happy. // scheduleResult.getItem() will always return non-null if scheduleResult.isAccepted() is true final Queue.Item item = scheduleResult.getItem(); if(scheduleResult.isAccepted() && item != null) { return new QueueItemImpl( pipeline.getOrganization(), item, pipeline, expectedBuildNumber, pipeline.getLink().rel("queue").rel(Long.toString(item.getId())), pipeline.getLink() ).toRun(); } else { throw new ServiceException.UnexpectedErrorException("Queue item request was not accepted"); } } else { throw new ServiceException.NotImplementedException("This pipeline type does not support being queued."); } }
Example #17
Source File: PipelineStepImpl.java From blueocean-plugin with MIT License | 5 votes |
private Object convert(String name, ParameterValue v) throws IOException, InterruptedException { if (v instanceof FileParameterValue) { FileParameterValue fv = (FileParameterValue) v; FilePath fp = new FilePath(node.getRun().getRootDir()).child(name); fp.copyFrom(fv.getFile()); return fp; } else { return v.getValue(); } }
Example #18
Source File: PhabricatorBuildWrapper.java From phabricator-jenkins-plugin with MIT License | 5 votes |
@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; }
Example #19
Source File: GitHubPRCause.java From github-integration-plugin with MIT License | 4 votes |
@Override public void fillParameters(List<ParameterValue> params) { GitHubPREnv.getParams(this, params); }
Example #20
Source File: GitHubEnv.java From github-integration-plugin with MIT License | 4 votes |
default ParameterValue param(boolean value) { return new BooleanParameterValue(toString(), value); }
Example #21
Source File: GitHubBranchCause.java From github-integration-plugin with MIT License | 4 votes |
@Override public void fillParameters(List<ParameterValue> params) { GitHubBranchEnv.getParams(this, params); }
Example #22
Source File: GitHubParametersAction.java From github-integration-plugin with MIT License | 4 votes |
public GitHubParametersAction(List<ParameterValue> params) { this.params = params; }
Example #23
Source File: NoDuplicatesParameterAction.java From DotCi with MIT License | 4 votes |
public NoDuplicatesParameterAction(List<ParameterValue> parametersValues) { super(parametersValues); }
Example #24
Source File: PipelineStepImpl.java From blueocean-plugin with MIT License | 4 votes |
private Object parseValue(InputStepExecution execution, JSONArray parameters, StaplerRequest request) throws IOException, InterruptedException { Map<String, Object> mapResult = new HashMap<String, Object>(); InputStep input = execution.getInput(); for(Object o: parameters){ JSONObject p = (JSONObject) o; String name = (String) p.get(NAME_ELEMENT); if(name == null){ throw new ServiceException.BadRequestException("name is required parameter element"); } ParameterDefinition d=null; for (ParameterDefinition def : input.getParameters()) { if (def.getName().equals(name)) d = def; } if (d == null) throw new ServiceException.BadRequestException("No such parameter definition: " + name); ParameterValue v = d.createValue(request, p); if (v == null) { continue; } mapResult.put(name, convert(name, v)); } // If a destination value is specified, push the submitter to it. String valueName = input.getSubmitterParameter(); if (valueName != null && !valueName.isEmpty()) { Authentication a = Jenkins.getAuthentication(); mapResult.put(valueName, a.getName()); } switch (mapResult.size()) { case 0: return null; // no value if there's no parameter case 1: return mapResult.values().iterator().next(); default: return mapResult; } }
Example #25
Source File: QueuedBuild.java From DotCi with MIT License | 4 votes |
@Override public List<ParameterValue> getParameters() { return Lists.newArrayList(); }
Example #26
Source File: Build.java From DotCi with MIT License | 4 votes |
@Exported public abstract List<ParameterValue> getParameters();
Example #27
Source File: GitHubEnv.java From github-integration-plugin with MIT License | 4 votes |
default ParameterValue param(String value) { return new StringParameterValue(toString(), escapeJava(trimToEmpty(value))); }
Example #28
Source File: GitHubTagCause.java From github-integration-plugin with MIT License | 4 votes |
@Override public void fillParameters(List<ParameterValue> params) { GitHubTagEnv.getParams(this, params); }
Example #29
Source File: GitHubEnv.java From github-integration-plugin with MIT License | votes |
void addParam(T cause, List<ParameterValue> params);
Example #30
Source File: GitHubCause.java From github-integration-plugin with MIT License | votes |
public abstract void fillParameters(List<ParameterValue> params);