@Override public String getShortDescription() { Executor e = build.getExecutor(); String eta = ""; if (e != null) { eta = Messages.BlockedBecauseOfBuildInProgress_ETA(e.getEstimatedRemainingTime()); } int lbn = build.getNumber(); return Messages.BlockedBecauseOfBuildInProgress_shortDescription(lbn, eta); }
/** * Performs an installation. */ private int install(ToolInstallation t, BuildIDs id, AbstractProject p) throws IOException, InterruptedException { Run b = p.getBuildByNumber(Integer.parseInt(id.number)); if (b==null) throw new IllegalStateException("No such build: "+id.number); Executor exec = b.getExecutor(); if (exec==null) throw new IllegalStateException(b.getFullDisplayName()+" is not building"); Node node = exec.getOwner().getNode(); if (node == null) { throw new IllegalStateException("The node " + exec.getOwner().getDisplayName() + " has been deleted"); } t = t.translate(node, EnvVars.getRemote(checkChannel()), new StreamTaskListener(stderr)); stdout.println(t.getHome()); return 0; }
/** * Gets the {@link Executor} building this job, if it's being built. * Otherwise null. */ final public Executor getExecutor() { return getExecutor(this); }
public Executor superGetExecutor() { return super.getExecutor(); }
@Override public Executor getExecutor() { return Run.getExecutor(getBuild()); }
@Override public synchronized void onStarted(Run run, TaskListener listener) { JenkinsMetricProviderImpl instance = instance(); if (instance != null) { List<Timer.Context> contextList = new ArrayList<Timer.Context>(); contextList.add(instance.jenkinsJobBuildingTime.time()); Executor executor = run.getExecutor(); if (executor != null) { Computer computer = executor.getOwner(); Timer timer = instance.getOrCreateTimer(computer); contextList.add(timer.time()); } contexts.put(run, contextList); } ScheduledRate.instance().addAction(run); }
public void addAction(Run run) { Executor executor = run.getExecutor(); if (executor == null) { return; } WorkUnit workUnit = executor.getCurrentWorkUnit(); if (workUnit == null) { return; } WorkUnitContext context = workUnit.context; if (context == null) { return; } TimeInQueueAction action; synchronized (actions) { action = actions.remove(context); } if (action != null) { run.addAction(action); } }
@Override public void interrupt(boolean forShutdown) { if (forShutdown) { return; } LOGGER.log(FINE, "interrupted {0}", cookie); // TODO save the BodyExecution somehow and call .cancel() here; currently we just interrupt the build as a whole: Executor masterExecutor = r.getExecutor(); if (masterExecutor != null) { masterExecutor.interrupt(); } else { // ? super.getExecutor().recordCauseOfInterruption(r, listener); } } @Override public boolean blocksRestart() {
@Override public void interrupt(boolean forShutdown) { if (forShutdown) { return; } LOGGER.log(FINE, "interrupted {0}", cookie); // TODO save the BodyExecution somehow and call .cancel() here; currently we just interrupt the build as a whole: Executor masterExecutor = r.getExecutor(); if (masterExecutor != null) { masterExecutor.interrupt(); } else { // ? super.getExecutor().recordCauseOfInterruption(r, listener); } } @Override public boolean blocksRestart() {
@Override @Exported public @CheckForNull Executor getExecutor() { initPython(); if (pexec.isImplemented(11)) { return (Executor) pexec.execPython("get_executor"); } else { return super.getExecutor(); } }
private void abortRunningJobsThatMatch(@Nonnull BitbucketCause bitbucketCause) { logger.fine("Looking for running jobs that match PR ID: " + bitbucketCause.getPullRequestId()); for (Object o : job.getBuilds()) { if (o instanceof Run) { Run<?,?> build = (Run<?,?>) o; if (build.isBuilding() && hasCauseFromTheSamePullRequest(build.getCauses(), bitbucketCause)) { logger.fine("Aborting build: " + build + " since PR is outdated"); setBuildDescription(build); final Executor executor = build.getExecutor(); if (executor == null){ throw new IllegalStateException("Executor can't be NULL"); } executor.interrupt(Result.ABORTED); } } } }
@Override public String getShortDescription() { Executor e = build.getExecutor(); String eta = ""; if (e != null) { eta = Messages.BlockedBecauseOfBuildInProgress_ETA(e.getEstimatedRemainingTime()); } int lbn = build.getNumber(); return Messages.BlockedBecauseOfBuildInProgress_shortDescription(lbn, eta); }
public static void attachFacet(Run<?, ?> run, TaskListener listener) { final Executor executor = run.getExecutor(); if (executor == null) { return; } final Computer owner = executor.getOwner(); DockerComputer dockerComputer; if (owner instanceof DockerComputer) { dockerComputer = (DockerComputer) owner; try { DockerFingerprints.addRunFacet( createRecordFor(dockerComputer), run ); } catch (IOException | ParseException e) { listener.error("Can't add Docker fingerprint to run."); LOG.error("Can't add fingerprint to run {}", run, e); } } } }
/** * Performs an installation. */ private int install(ToolInstallation t, BuildIDs id, AbstractProject p) throws IOException, InterruptedException { Run b = p.getBuildByNumber(Integer.parseInt(id.number)); if (b==null) throw new IllegalStateException("No such build: "+id.number); Executor exec = b.getExecutor(); if (exec==null) throw new IllegalStateException(b.getFullDisplayName()+" is not building"); Node node = exec.getOwner().getNode(); if (node == null) { throw new IllegalStateException("The node " + exec.getOwner().getDisplayName() + " has been deleted"); } t = t.translate(node, EnvVars.getRemote(checkChannel()), new StreamTaskListener(stderr)); stdout.println(t.getHome()); return 0; }
public void onBuildFinalized(Run r) { Computer computer = r.getExecutor().getOwner(); // A build just finished, so let the AvailabilityMonitor // associated with its node wake up any workers who may be // waiting for the lock. AvailabilityMonitor availability = null; synchronized(gewtHandles) { for (ExecutorWorkerThread t : gewtHandles) { if (t.getComputer() == computer) { availability = t.getAvailability(); } } } if (availability != null) { availability.wake(); } }
@Override protected void performDelete() throws IOException, InterruptedException { // if a build is in progress. Cancel it. RunT lb = getLastBuild(); if (lb != null) { Executor e = lb.getExecutor(); if (e != null) { e.interrupt(); // should we block until the build is cancelled? } } CascadingUtil.unlinkProjectFromCascadingParents(getCascadingProject(), name); super.performDelete(); }
@Override protected void performDelete() throws IOException, InterruptedException { // if a build is in progress. Cancel it. RunT lb = getLastBuild(); if (lb != null) { Executor e = lb.getExecutor(); if (e != null) { e.interrupt(); // should we block until the build is cancelled? } } CascadingUtil.unlinkProjectFromCascadingParents(getCascadingProject(), name); super.performDelete(); }
@Override protected void performDelete() throws IOException, InterruptedException { // if a build is in progress. Cancel it. RunT lb = getLastBuild(); if (lb != null) { Executor e = lb.getExecutor(); if (e != null) { e.interrupt(); // should we block until the build is cancelled? } } CascadingUtil.unlinkProjectFromCascadingParents(getCascadingProject(), name); super.performDelete(); }
/** * Performs an installation. */ private int install(ToolInstallation t, BuildIDs id, AbstractProject p) throws IOException, InterruptedException { Run b = p.getBuildByNumber(Integer.parseInt(id.number)); if (b==null) throw new AbortException("No such build: "+id.number); Executor exec = b.getExecutor(); if (exec==null) throw new AbortException(b.getFullDisplayName()+" is not building"); Node node = exec.getOwner().getNode(); if (t instanceof NodeSpecific) { NodeSpecific n = (NodeSpecific) t; t = (ToolInstallation)n.forNode(node,new StreamTaskListener(stderr)); } if (t instanceof EnvironmentSpecific) { EnvironmentSpecific e = (EnvironmentSpecific) t; t = (ToolInstallation)e.forEnvironment(EnvVars.getRemote(channel)); } stdout.println(t.getHome()); return 0; }
private void cancelPreviousPullRequestBuilds(Job job, TeamPullRequestMergedDetailsAction pullReqeuestMergedDetails, Queue queue) { RunList<?> allBuilds = job.getBuilds(); for (Run run : allBuilds) { TeamPullRequestMergedDetailsAction cause = run.getAction(TeamPullRequestMergedDetailsAction.class); if (cause != null && run.isBuilding()) { if (cause instanceof TeamPullRequestMergedDetailsAction && cause.gitPullRequest.getPullRequestId() == pullReqeuestMergedDetails.gitPullRequest.getPullRequestId()) { LOGGER.info("Canceling previously triggered Job: " + run.getFullDisplayName()); Executor executor = run.getExecutor(); if (executor != null) executor.doStop(); Queue.Item item = queue.getItem(run.getQueueId()); if (item != null) queue.cancel(item); } } } }