@CheckForNull Queue.Item scheduleBuild2(int quietPeriod, List<Action> actions) { if (!asJob().isBuildable()) return null; List<Action> queueActions = new ArrayList<Action>(actions); if (isParameterized() && Util.filter(queueActions, ParametersAction.class).isEmpty()) { queueActions.add(new ParametersAction(getDefaultParametersValues())); } return Jenkins.getInstance().getQueue().schedule2(asJob(), quietPeriod, queueActions).getItem(); }
/** * @deprecated as of 1.521 * Use {@link #schedule2(Task, int, List)} */ @Deprecated public WaitingItem schedule(Task p, int quietPeriod, List<Action> actions) { return schedule2(p, quietPeriod, actions).getCreateItem(); }
/** * Opposite of {@link #isRefused()} */ public final boolean isAccepted() { return !isRefused(); }
@Override public ScheduleResult answer(InvocationOnMock invocation) throws Throwable { Object[] arguments = invocation.getArguments(); Queue.WaitingItem i = new Queue.WaitingItem( new GregorianCalendar(), (Queue.Task)arguments[0], (List<Action>)arguments[2]); return ScheduleResult.created(i); } });
/** * Starts the build with the actions that are passed in. * * @param actions Can be null. * @param c Reason for starting the build * @return true if the build has been scheduled */ public boolean scheduleBuild(List<? extends Action> actions, Cause c) { final Jenkins jenkins = Jenkins.getInstance(); if (jenkins == null) { LOGGER.log(Level.WARNING, "Cannot schedule the build {0}. Jenkins is not ready", this); return false; } List<Action> allActions = new ArrayList<Action>(); if(actions != null) { for (Action a : actions) { // SECURITY-170 if (a instanceof ParametersAction) { allActions.add(MatrixChildParametersAction.create((ParametersAction) a)); } else { allActions.add(a); } } } allActions.add(new ParentBuildAction()); allActions.add(new CauseAction(c)); return jenkins.getQueue().schedule2(this, getQuietPeriod(), allActions ).isAccepted(); }
public void buildWithParameters(StaplerRequest req, StaplerResponse rsp, @CheckForNull TimeDuration delay) throws IOException, ServletException { List<ParameterValue> values = new ArrayList<ParameterValue>(); for (ParameterDefinition d: parameterDefinitions) { ParameterValue value = d.createValue(req); if (value != null) { values.add(value); } } if (delay==null) delay=new TimeDuration(TimeUnit.MILLISECONDS.convert(getJob().getQuietPeriod(), TimeUnit.SECONDS)); Queue.Item item = Jenkins.getInstance().getQueue().schedule2( getJob(), delay.getTimeInSeconds(), new ParametersAction(values), ParameterizedJobMixIn.getBuildCause(getJob(), req)).getItem(); if (item != null) { rsp.sendRedirect(SC_CREATED, req.getContextPath() + '/' + item.getUrl()); } else { rsp.sendRedirect("."); } }
/** * Convenience wrapper method around {@link #schedule(Task, int, List)} */ public @CheckForNull WaitingItem schedule(Task p, int quietPeriod, Action... actions) { return schedule2(p, quietPeriod, actions).getCreateItem(); }
/** * Opposite of {@link #isRefused()} */ public final boolean isAccepted() { return !isRefused(); }
/** * Standard implementation of {@link ParameterizedJob#doBuild}. */ @SuppressWarnings("deprecation") public final void doBuild(StaplerRequest req, StaplerResponse rsp, @QueryParameter TimeDuration delay) throws IOException, ServletException { if (delay == null) { delay=new TimeDuration(TimeUnit.MILLISECONDS.convert(asJob().getQuietPeriod(), TimeUnit.SECONDS)); } if (!asJob().isBuildable()) { throw HttpResponses.error(SC_CONFLICT, new IOException(asJob().getFullName() + " is not buildable")); } // if a build is parameterized, let that take over ParametersDefinitionProperty pp = asJob().getProperty(ParametersDefinitionProperty.class); if (pp != null && !req.getMethod().equals("POST")) { // show the parameter entry form. req.getView(pp, "index.jelly").forward(req, rsp); return; } hudson.model.BuildAuthorizationToken.checkPermission(asJob(), asJob().getAuthToken(), req, rsp); if (pp != null) { pp._doBuild(req, rsp, delay); return; } Queue.Item item = Jenkins.getInstance().getQueue().schedule2(asJob(), delay.getTimeInSeconds(), getBuildCause(asJob(), req)).getItem(); if (item != null) { rsp.sendRedirect(SC_CREATED, req.getContextPath() + '/' + item.getUrl()); } else { rsp.sendRedirect("."); } }
/** * Convenience wrapper method around {@link #schedule(Task, int, List)} */ public @CheckForNull WaitingItem schedule(Task p, int quietPeriod, Action... actions) { return schedule2(p, quietPeriod, actions).getCreateItem(); }
if (scheduleResult.isRefused()) { throw new AbortException("Failed to trigger build of " + item.getFullName());
/** * Duck-types {@link ParameterizedJobMixIn#scheduleBuild2(int, Action...)}. * @param quietPeriod seconds to wait before starting (normally 0) * @param actions various actions to associate with the scheduling, such as {@link ParametersAction} or * {@link CauseAction} * @return a handle by which you may wait for the build to complete (or just start); or null if the build was not * actually scheduled for some reason */ @CheckForNull public Queue.Item scheduleBuild2(int quietPeriod, Action... actions) { if (!isBuildable()) { return null; } return Queue.getInstance().schedule2(this, quietPeriod, Arrays.asList(actions)).getItem(); }
/** * @deprecated as of 1.521 * Use {@link #schedule2(Task, int, List)} */ @Deprecated public WaitingItem schedule(Task p, int quietPeriod, List<Action> actions) { return schedule2(p, quietPeriod, actions).getCreateItem(); }
/** * Duck-types {@link ParameterizedJobMixIn#scheduleBuild2(int, Action...)}. * @param quietPeriod seconds to wait before starting (normally 0) * @param actions various actions to associate with the scheduling, such as {@link ParametersAction} or * {@link CauseAction} * @return a handle by which you may wait for the build to complete (or just start); or null if the build was not * actually scheduled for some reason */ @CheckForNull public Queue.Item scheduleBuild2(int quietPeriod, Action... actions) { if (!isBuildable()) { return null; } Jenkins j = Jenkins.getInstance(); if (j == null) { return null; } return j.getQueue().schedule2(this, quietPeriod, Arrays.asList(actions)).getItem(); }
public boolean start() throws Exception { final PlaceholderTask task = new PlaceholderTask(getContext(), step.getLabel()); Queue.WaitingItem waitingItem = Queue.getInstance().schedule2(task, 0).getCreateItem(); if (waitingItem == null) {
@CheckForNull Queue.Item scheduleBuild2(int quietPeriod, List<Action> actions) { if (!asJob().isBuildable()) return null; List<Action> queueActions = new ArrayList<Action>(actions); if (isParameterized() && Util.filter(queueActions, ParametersAction.class).isEmpty()) { queueActions.add(new ParametersAction(getDefaultParametersValues())); } return Jenkins.getInstance().getQueue().schedule2(asJob(), quietPeriod, queueActions).getItem(); }
String description = "Container building " + run.getParent().getFullName(); Queue.Item item = Queue.getInstance().schedule2(task, 0).getCreateItem(); if (item == null) {