use of com.cloudbees.hudson.plugins.folder.AbstractFolder in project blueocean-plugin by jenkinsci.
the class FavoriteContainerImpl method iterator.
@Override
public Iterator<BlueFavorite> iterator(int start, int limit) {
List<BlueFavorite> favorites = new ArrayList<>();
Iterator<Item> favoritesIterator = Favorites.getFavorites(user.user).iterator();
Utils.skip(favoritesIterator, start);
int count = 0;
while (count < limit && favoritesIterator.hasNext()) {
Item item = favoritesIterator.next();
if (item instanceof AbstractFolder) {
continue;
}
BlueFavorite blueFavorite = FavoriteUtil.getFavorite(item);
if (blueFavorite != null) {
favorites.add(blueFavorite);
count++;
}
}
return favorites.iterator();
}
use of com.cloudbees.hudson.plugins.folder.AbstractFolder in project blueocean-plugin by jenkinsci.
the class GithubIssueTest method changeSetJobParentNotMultibranch.
@Test
public void changeSetJobParentNotMultibranch() throws Exception {
AbstractFolder project = mock(AbstractFolder.class);
Job job = mock(MockJob.class);
Run run = mock(Run.class);
ChangeLogSet logSet = mock(ChangeLogSet.class);
ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);
when(project.getProperties()).thenReturn(new DescribableList(project));
when(entry.getParent()).thenReturn(logSet);
when(logSet.getRun()).thenReturn(run);
when(run.getParent()).thenReturn(job);
when(job.getParent()).thenReturn(project);
when(entry.getMsg()).thenReturn("Closed #123 #124");
Collection<BlueIssue> resolved = BlueIssueFactory.resolve(entry);
Assert.assertEquals(0, resolved.size());
}
use of com.cloudbees.hudson.plugins.folder.AbstractFolder in project hubot-steps-plugin by jenkinsci.
the class HubotSite method get.
public static HubotSite get(final Job<?, ?> job, final TaskListener listener, final String siteName) {
HubotSite hubotSite = null;
HubotSite defaultSite = null;
ItemGroup parent = job.getParent();
String folderName = null;
// Site from folder(s).
try {
while (parent != null) {
if (parent instanceof AbstractFolder) {
AbstractFolder folder = (AbstractFolder) parent;
if (folderName == null) {
folderName = folder.getName();
}
HubotFolderProperty jfp = (HubotFolderProperty) folder.getProperties().get(HubotFolderProperty.class);
if (jfp != null) {
HubotSite[] sites = jfp.getSites();
if (sites != null && sites.length > 0) {
for (HubotSite site : sites) {
HubotSite cloneSite = site.clone();
if (cloneSite.isUseFolderName()) {
cloneSite.setRoom(folder.getName());
}
if (siteName != null) {
if (cloneSite.getName().equalsIgnoreCase(siteName) && hubotSite == null) {
hubotSite = cloneSite;
}
} else {
if (cloneSite.isDefaultSite() && defaultSite == null) {
defaultSite = cloneSite;
}
}
}
}
}
}
if (parent instanceof Item) {
parent = ((Item) parent).getParent();
} else {
parent = null;
}
}
// Global Sites.
if (hubotSite == null && defaultSite == null) {
for (HubotSite site : new GlobalConfig().getSites()) {
HubotSite cloneSite = site.clone();
if (site.isUseFolderName()) {
if (folderName != null) {
cloneSite.setRoom(folderName);
}
}
if (siteName != null) {
if (cloneSite.getName().equalsIgnoreCase(siteName) && hubotSite == null) {
hubotSite = cloneSite;
}
} else {
if (cloneSite.isDefaultSite() && defaultSite == null) {
defaultSite = cloneSite;
}
}
}
}
} catch (Exception e) {
LOGGER.error("Unable to get hubot site", e);
}
return hubotSite == null ? defaultSite : hubotSite;
}
Aggregations