private BuildPreferenceJobProperty getBuildPreferenceJobProperty(SubTask subtask) { if(!(subtask instanceof Job)) { return null; } if(subtask instanceof MatrixConfiguration) { MatrixConfiguration conf = (MatrixConfiguration)subtask; return conf.getParent().getProperty(BuildPreferenceJobProperty.class); } Job<?,?> job = (Job<?,?>)subtask; return job.getProperty(BuildPreferenceJobProperty.class); }
@Override public Collection<? extends SubTask> getSubTasks() { initPython(); if (pexec.isImplemented(9)) { return (Collection) pexec.execPython("get_sub_tasks"); } else { return super.getSubTasks(); } }
/** * This needs to be overridden, because {@link AbstractProject} reads the * properties field directly; which circumvents inheritance. */ @Override public List<SubTask> getSubTasks() { List<SubTask> r = new ArrayList<SubTask>(); r.add(this); for (SubTaskContributor euc : SubTaskContributor.all()) { r.addAll(euc.forProject(this)); } for (JobProperty<?> p : this.getAllProperties()) { r.addAll(p.getSubTasks()); } return r; }
@Override public Label getAssignedLabel(SubTask task) { return Label.get(assignedNodeName); }
@Nonnull @Override public SubTask getParent() { return dockerTask; }
public synchronized int abortRunning(int number) throws IllegalAccessException { int aborted = 0; Computer[] computers = getJenkinsInstance().getComputers(); for (Computer computer : computers) { if (isNull(computer)) { continue; } List<Executor> executors = computer.getExecutors(); executors.addAll(computer.getOneOffExecutors()); for (Executor executor : executors) { if (isNull(executor) || !executor.isBusy() || nonNull(executor.getCauseOfDeath()) || !getInterruptCauses(executor).isEmpty() || getInterruptStatus(executor) == Result.ABORTED) { continue; } Queue.Executable executable = executor.getCurrentExecutable(); final SubTask parent = executable.getParent(); if (!(executable instanceof Run)) { continue; } final Run executableRun = (Run) executable; if (!(parent instanceof Job)) { continue; } final Job parentJob = (Job) parent; if (!parentJob.getFullName().equals(job.getFullName())) { // name doesn't match continue; } if (executableRun.getResult() == Result.ABORTED) { // was already aborted continue; } if (executableRun instanceof MatrixRun) { // the whole MatrixBuild will be aborted continue; } // if (executable instanceof MatrixBuild) { // final MatrixBuild executable1 = (MatrixBuild) executable; // executable1.doStop() // } final GitHubPRCause causeAction = (GitHubPRCause) executableRun.getCause(GitHubPRCause.class); if (nonNull(causeAction) && causeAction.getNumber() == number) { LOGGER.info("Aborting '{}', by interrupting '{}'", executableRun, executor); executor.interrupt(Result.ABORTED, new NewPRInterruptCause()); aborted++; } } } return aborted; }
public SubTask getParent() { return DeployNowTask.this; }
@Override public Label getAssignedLabel(@Nonnull SubTask task) { return new LabelAtom(uuid); }
public Collection<? extends SubTask> superGetSubTasks() { return super.getSubTasks(); }
/** * Scores the nodes depending on build results on those nodes. * * @param task * @param wc * @param m * @param nodesScore */ @Override public boolean updateScores(Task task, WorkChunk wc, Mapping m, NodesScore nodesScore) { for(SubTask subtask: wc) { if(!(subtask instanceof AbstractProject)) { return true; } AbstractProject<?,?> project = (AbstractProject<?, ?>)subtask; Set<Node> nodeSet = new HashSet<Node>(nodesScore.getNodes()); AbstractBuild<?,?> build = project.getLastBuild(); for( int pastNum = 0; pastNum < getNumberOfBuilds() && build != null; ++pastNum, build = build.getPreviousBuild() ) { Node node = build.getBuiltOn(); if(!nodeSet.contains(node)) { continue; } int scale = getScale() + getScaleAdjustForOlder() * pastNum; if(Result.SUCCESS == build.getResult()) { nodesScore.addScore(node, getScoreForSuccess() * scale); nodeSet.remove(node); } else if(Result.FAILURE == build.getResult()) { nodesScore.addScore(node, getScoreForFailure() * scale); nodeSet.remove(node); } else if(Result.UNSTABLE == build.getResult()) { nodesScore.addScore(node, getScoreForUnstable() * scale); nodeSet.remove(node); } } } return true; }
public TriggerOtherProjectProperty(SubTask ... tasks) { subTaskList = Arrays.asList(tasks); }
@Override public Collection<? extends SubTask> getSubTasks() { return subTaskList; }
@Override public Label getAssignedLabel(SubTask task) { // TODO Auto-generated method stub return labelAtom; }