public void prepareWorkspace(AbstractBuild<?,?> build, FilePath ws, final TaskListener listener) throws IOException, InterruptedException { final String name = build.getProject().getFullName(); ws.act(new PrepareWorkspace(name, listener)); } private class PrepareWorkspace extends MasterToSlaveFileCallable<Void> {
@Override public boolean shouldTriggerBuild(AbstractBuild build, TaskListener listener, List<Action> actions) { AbstractProject downstream = getDownstreamProject(); if (Jenkins.getInstance().getItemByFullName(downstream.getFullName()) != downstream) { // this checks Item.READ also on parent folders LOGGER.log(Level.WARNING, "Running as {0} cannot even see {1} for trigger from {2}", new Object[] {Jenkins.getAuthentication().getName(), downstream, getUpstreamProject()}); return false; // do not even issue a warning to build log } if (!downstream.hasPermission(Item.BUILD)) { listener.getLogger().println(Messages.BuildTrigger_you_have_no_permission_to_build_(ModelHyperlinkNote.encodeTo(downstream))); return false; } return build.getResult().isBetterOrEqualTo(threshold); } });
if (Jenkins.getInstance().getItemByFullName(p.getFullName()) == p) { String name = ModelHyperlinkNote.encodeTo(p); if (scheduled) {
@Override public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException { super.onLoad(parent, name); if (buildMixIn == null) { buildMixIn = createBuildMixIn(); } buildMixIn.onLoad(parent, name); builds = buildMixIn.getRunMap(); triggers().setOwner(this); for (Trigger t : triggers()) { try { t.start(this, Items.currentlyUpdatingByXml()); } catch (Throwable e) { LOGGER.log(Level.WARNING, "could not start trigger while loading project '" + getFullName() + "'", e); } } if(scm==null) scm = new NullSCM(); // perhaps it was pointing to a plugin that no longer exists. if(transientActions==null) transientActions = new Vector<Action>(); // happens when loaded from disk updateTransientActions(); }
/** * Used for CLI binding. */ @CLIResolver public static AbstractProject resolveForCLI( @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException { AbstractProject item = Jenkins.getInstance().getItemByFullName(name, AbstractProject.class); if (item==null) { AbstractProject project = AbstractProject.findNearest(name); throw new CmdLineException(null, project == null ? Messages.AbstractItem_NoSuchJobExistsWithoutSuggestion(name) : Messages.AbstractItem_NoSuchJobExists(name, project.getFullName())); } return item; }
/** * Obtains the {@link WorkspaceSnapshot} object that this {@link SCM} points to, * or throws {@link hudson.fsp.WorkspaceSnapshotSCM.ResolvedFailedException} upon failing. * * @return never null. */ public Snapshot resolve() throws ResolvedFailedException { Jenkins h = Jenkins.getInstance(); AbstractProject<?,?> job = h.getItemByFullName(jobName, AbstractProject.class); if(job==null) { if(h.getItemByFullName(jobName)==null) { AbstractProject nearest = AbstractProject.findNearest(jobName); throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchJob(jobName,nearest.getFullName())); } else throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_IncorrectJobType(jobName)); } PermalinkList permalinks = job.getPermalinks(); Permalink p = permalinks.get(permalink); if(p==null) throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchPermalink(permalink,jobName)); AbstractBuild<?,?> b = (AbstractBuild<?,?>)p.resolve(job); if(b==null) throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoBuild(permalink,jobName)); WorkspaceSnapshot snapshot = b.getAction(WorkspaceSnapshot.class); if(snapshot==null) throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoWorkspace(jobName,permalink)); return new Snapshot(snapshot,b); }
public TestResultAction(String jobs, AbstractBuild<?,?> owner) { super(owner); if(jobs==null) { // resolve null as the transitive downstream jobs StringBuilder buf = new StringBuilder(); for (AbstractProject p : getProject().getTransitiveDownstreamProjects()) { if(buf.length()>0) buf.append(','); buf.append(p.getFullName()); } jobs = buf.toString(); } this.jobs = jobs; }
public AutoCompletionCandidates doAutoCompleteSubProjects( @QueryParameter String value) { AutoCompletionCandidates candidates = new AutoCompletionCandidates(); Set<AbstractProject> projects = getSubProjects(); for (AbstractProject project : projects) { if (project.getFullName().startsWith(value)) { if (project.hasPermission(Item.READ)) { candidates.add(project.getFullName()); } } } return candidates; }
public static boolean equals(AbstractBuild b1, AbstractBuild b2) { return b1 != null && b2 != null && b1.getProject().getFullName().equals(b2.getProject().getFullName()) && b1.getNumber() == b2.getNumber(); } }
public PromotionTargetAction(AbstractBuild<?,?> build) { jobName = build.getParent().getFullName(); number = build.getNumber(); }
@Restricted(NoExternalUse.class) public FormValidation doCheckBuilderTimeout( @QueryParameter String builderTimeout, @AncestorInPath AbstractProject<?, ?> job ) { if (!job.getFullName().equals(job.getAssignedLabelString())) return FormValidation.ok(); return FormValidation.validatePositiveInteger(builderTimeout); } }
@Restricted(NoExternalUse.class) public FormValidation doCheckBuilderSize( @QueryParameter String builderSize, @AncestorInPath AbstractProject<?, ?> job ) { if (!job.getFullName().equals(job.getAssignedLabelString())) return FormValidation.ok(); return FormValidation.validateRequired(builderSize); } }
/** * Returns a mocked version of an AbstractProject, where getFullName() returns the provided name. * @param fullName - the name of the project. * @return a mock. */ private AbstractProject mockProject(String fullName) { AbstractProject project = PowerMockito.mock(AbstractProject.class); when(project.getFullName()).thenReturn(fullName); return project; }
@JellyAccessible public String getProjectName() { // TODO: probably want to use the JobUUID to make the paths resilient to job renames, and avoid needing to deal with encoding return projectNameCodec.encode(getBuild().getProject().getFullName()); }
/** * {@inheritDoc} */ @Override public ChangeLog getChangeLog(String jobname, Integer buildNumber) throws NoSuchJobException, NoSuchBuildException { final AbstractBuild<?, ?> build = getHudsonBuild(jobname, buildNumber); log.fine("Getting changelog of build: " + build.getNumber() + " of job " + build.getParent().getFullName()); return DozerUtils.getMapper().map(build.getChangeSet(), ChangeLog.class); }
private Node prepareExecutorFor(final Queue.BuildableItem item, final AbstractProject job) throws Descriptor.FormException, IOException, InterruptedException { LOGGER.info("Creating a container slave to host " + job.toString() + ", item id " + item.getId()); // Immediately create a slave for this item // Real provisioning will happen later String slaveName = "Container for item " + item.getId(); String description = "Container slave for building " + job.getFullName(); DockerSlaves plugin = DockerSlaves.get(); return new DockerSlave(slaveName, description, null, plugin.createStandardJobProvisionerFactory(job),item); }
private Node prepareExecutorFor(final Queue.BuildableItem item, final AbstractProject job) throws Descriptor.FormException, IOException, InterruptedException { LOGGER.info("Creating a Container slave to host " + job.toString() + "#" + job.getNextBuildNumber()); // Immediately create a slave for this item // Real provisioning will happen later String slaveName = "Container for " +job.getName() + "#" + job.getNextBuildNumber(); String description = "Container slave for building " + job.getFullName(); DockerSlaves plugin = DockerSlaves.get(); return new DockerSlave(slaveName, description, null, plugin.createStandardJobProvisionerFactory(job),item); }
/** * Used for CLI binding. */ @CLIResolver public static AbstractProject resolveForCLI( @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException { AbstractProject item = Hudson.getInstance().getItemByFullName(name, AbstractProject.class); if (item==null) throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName())); return item; } }
/** * Used for CLI binding. */ @CLIResolver public static AbstractItem resolveForCLI( @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException { AbstractItem item = Hudson.getInstance().getItemByFullName(name, AbstractItem.class); if (item==null) throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName())); return item; } }
/** * Used for CLI binding. */ @CLIResolver public static AbstractItem resolveForCLI( @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException { AbstractItem item = Hudson.getInstance().getItemByFullName(name, AbstractItem.class); if (item==null) throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName())); return item; } }