Java Code Examples for jenkins.model.ParameterizedJobMixIn#ParameterizedJob
The following examples show how to use
jenkins.model.ParameterizedJobMixIn#ParameterizedJob .
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: JobHelper.java From github-integration-plugin with MIT License | 6 votes |
/** * support matrix plugin. * * @see JobInfoHelpers#triggerFrom(hudson.model.Job, java.lang.Class) */ @CheckForNull public static <T extends Trigger> T triggerFrom(final Job<?, ?> job, Class<T> tClass) { Job<?, ?> guessJob; if (job instanceof MatrixConfiguration) { guessJob = ((MatrixConfiguration) job).getParent(); } else { guessJob = job; } if (guessJob instanceof AbstractProject<?, ?>) { final AbstractProject<?, ?> abstractProject = (AbstractProject<?, ?>) guessJob; return abstractProject.getTrigger(tClass); } else if (guessJob instanceof ParameterizedJobMixIn.ParameterizedJob) { ParameterizedJobMixIn.ParameterizedJob pJob = (ParameterizedJobMixIn.ParameterizedJob) guessJob; for (Object candidate : pJob.getTriggers().values()) { if (tClass.isInstance(candidate)) { return tClass.cast(candidate); } } } return null; }
Example 2
Source File: Disabler.java From blueocean-plugin with MIT License | 5 votes |
public static void makeDisabled(Object item, boolean b) throws IOException { if (item instanceof AbstractFolder) { Disabler.makeDisabled((AbstractFolder) item, b); } if (item instanceof AbstractProject) { Disabler.makeDisabled((AbstractProject) item, b); } if (item instanceof ParameterizedJobMixIn.ParameterizedJob ) { Disabler.makeDisabled((ParameterizedJobMixIn.ParameterizedJob ) item, b); } }
Example 3
Source File: Disabler.java From blueocean-plugin with MIT License | 5 votes |
@SuppressFBWarnings(value = "NP_BOOLEAN_RETURN_NULL", justification = "isDisabled will return null if the job type doesn't support it") public static Boolean isDisabled(Object item) { if (item instanceof AbstractFolder) { return Disabler.isDisabled((AbstractFolder) item); } if (item instanceof AbstractProject) { return Disabler.isDisabled((AbstractProject) item); } if (item instanceof ParameterizedJobMixIn.ParameterizedJob ) { return Disabler.isDisabled((ParameterizedJobMixIn.ParameterizedJob ) item); } return null; }
Example 4
Source File: JenkinsRule.java From jenkins-test-harness with MIT License | 5 votes |
/** * Runs specified job and asserts that in finished with given build result. * @since TODO */ @Nonnull public <J extends Job<J,R> & ParameterizedJobMixIn.ParameterizedJob<J,R>,R extends Run<J,R> & Queue.Executable> R buildAndAssertStatus(@Nonnull Result status, @Nonnull J job) throws Exception { final QueueTaskFuture<R> f = new ParameterizedJobMixIn<J, R>() { @Override protected J asJob() { return job; } }.scheduleBuild2(0); return assertBuildStatus(status, f); }
Example 5
Source File: GitLabPushTrigger.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
public static GitLabPushTrigger getFromJob(Job<?, ?> job) { GitLabPushTrigger trigger = null; if (job instanceof ParameterizedJobMixIn.ParameterizedJob) { ParameterizedJobMixIn.ParameterizedJob p = (ParameterizedJobMixIn.ParameterizedJob) job; Collection<Trigger> triggerList = p.getTriggers().values(); for (Trigger t : triggerList) { if (t instanceof GitLabPushTrigger) { trigger = (GitLabPushTrigger) t; } } } return trigger; }
Example 6
Source File: OpenMergeRequestPushHookTriggerHandler.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
@Override public void handle(Job<?, ?> job, PushHook hook, boolean ciSkip, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) { try { if (job instanceof ParameterizedJobMixIn.ParameterizedJob) { ParameterizedJob project = (ParameterizedJobMixIn.ParameterizedJob) job; GitLabConnectionProperty property = job.getProperty(GitLabConnectionProperty.class); Collection<Trigger> triggerList = project.getTriggers().values(); for (Trigger t : triggerList) { if (t instanceof GitLabPushTrigger) { final GitLabPushTrigger trigger = (GitLabPushTrigger) t; Integer projectId = hook.getProjectId(); if (property != null && property.getClient() != null && projectId != null && trigger != null) { GitLabClient client = property.getClient(); for (MergeRequest mergeRequest : getOpenMergeRequests(client, projectId.toString())) { if (mergeRequestLabelFilter.isMergeRequestAllowed(mergeRequest.getLabels())) { handleMergeRequest(job, hook, ciSkip, branchFilter, client, mergeRequest); } } } } } } else { LOGGER.log(Level.FINE, "Not a ParameterizedJob: {0}",LoggerUtil.toArray(job.getClass().getName())); } } catch (WebApplicationException | ProcessingException e) { LOGGER.log(Level.WARNING, "Failed to communicate with gitlab server to determine if this is an update for a merge request: " + e.getMessage(), e); } }
Example 7
Source File: OpenMergeRequestPushHookTriggerHandler.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
private void scheduleBuild(Job<?, ?> job, Action[] actions) { int projectBuildDelay = 0; if (job instanceof ParameterizedJobMixIn.ParameterizedJob) { ParameterizedJobMixIn.ParameterizedJob abstractProject = (ParameterizedJobMixIn.ParameterizedJob) job; if (abstractProject.getQuietPeriod() > projectBuildDelay) { projectBuildDelay = abstractProject.getQuietPeriod(); } } retrieveScheduleJob(job).scheduleBuild2(projectBuildDelay, actions); }
Example 8
Source File: AbstractWebHookTriggerHandler.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
protected void scheduleBuild(Job<?, ?> job, Action[] actions) { int projectBuildDelay = 0; if (job instanceof ParameterizedJobMixIn.ParameterizedJob) { ParameterizedJobMixIn.ParameterizedJob abstractProject = (ParameterizedJobMixIn.ParameterizedJob) job; if (abstractProject.getQuietPeriod() > projectBuildDelay) { projectBuildDelay = abstractProject.getQuietPeriod(); } } retrieveScheduleJob(job).scheduleBuild2(projectBuildDelay, actions); }
Example 9
Source File: Disabler.java From blueocean-plugin with MIT License | 4 votes |
public static void makeDisabled(ParameterizedJobMixIn.ParameterizedJob job, boolean b) throws IOException { job.makeDisabled(b); }
Example 10
Source File: Disabler.java From blueocean-plugin with MIT License | 4 votes |
public static Boolean isDisabled(ParameterizedJobMixIn.ParameterizedJob job) { return job.isDisabled(); }
Example 11
Source File: GogsTrigger.java From gogs-webhook-plugin with MIT License | 4 votes |
@Override public boolean isApplicable(Item item) { return item instanceof Job && SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(item) != null && item instanceof ParameterizedJobMixIn.ParameterizedJob; }
Example 12
Source File: GogsPayloadProcessor.java From gogs-webhook-plugin with MIT License | 4 votes |
public GogsResults triggerJobs(String jobName, String deliveryID) { SecurityContext saveCtx = ACL.impersonate(ACL.SYSTEM); GogsResults result = new GogsResults(); try { BuildableItem project = GogsUtils.find(jobName, BuildableItem.class); if (project != null) { GogsTrigger gTrigger = null; Cause cause = new GogsCause(deliveryID); if (project instanceof ParameterizedJobMixIn.ParameterizedJob) { ParameterizedJobMixIn.ParameterizedJob pJob = (ParameterizedJobMixIn.ParameterizedJob) project; for (Trigger trigger : pJob.getTriggers().values()) { if (trigger instanceof GogsTrigger) { gTrigger = (GogsTrigger) trigger; break; } } } if (gTrigger != null) { SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(project); GogsPayload gogsPayload = new GogsPayload(this.payload); if (item != null) { item.scheduleBuild2(0, gogsPayload); } } else { project.scheduleBuild(0, cause); } result.setMessage(String.format("Job '%s' is executed", jobName)); } else { String msg = String.format("Job '%s' is not defined in Jenkins", jobName); result.setStatus(404, msg); LOGGER.warning(msg); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); LOGGER.severe(sw.toString()); } finally { SecurityContextHolder.setContext(saveCtx); } return result; }
Example 13
Source File: JenkinsRule.java From jenkins-test-harness with MIT License | 4 votes |
@Nonnull public <J extends Job<J,R> & ParameterizedJobMixIn.ParameterizedJob<J,R>,R extends Run<J,R> & Queue.Executable> R buildAndAssertSuccess(@Nonnull J job) throws Exception { return buildAndAssertStatus(Result.SUCCESS, job); }
Example 14
Source File: GitHubTriggerDescriptor.java From github-integration-plugin with MIT License | 4 votes |
@Override public boolean isApplicable(Item item) { return item instanceof Job && nonNull(SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(item)) && item instanceof ParameterizedJobMixIn.ParameterizedJob; }
Example 15
Source File: GitLabPushTrigger.java From gitlab-plugin with GNU General Public License v2.0 | 4 votes |
@Override public boolean isApplicable(Item item) { return item instanceof Job && SCMTriggerItems.asSCMTriggerItem(item) != null && item instanceof ParameterizedJobMixIn.ParameterizedJob; }