本文整理汇总了Java中hudson.model.TopLevelItem类的典型用法代码示例。如果您正苦于以下问题:Java TopLevelItem类的具体用法?Java TopLevelItem怎么用?Java TopLevelItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TopLevelItem类属于hudson.model包,在下文中一共展示了TopLevelItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: migrateDataTest
import hudson.model.TopLevelItem; //导入依赖的package包/类
/**
* Utility to aid in performing a round trip migration test on a <code>CpwrScmConfiguration</code> configuration.
* <p>
* An existing project is loaded, migrated, saved, and reloaded where the original configuration is compared against
* the reloaded configuration. The test project is loaded from a .zip file that mimics a Jenkins project's
* layout within.
*
* See test resource for the migration test: src/test/resources/com.compuware.jenkins.scm/<test>/<test method>.zip
*
* @param jenkinsRule
* the Jenkins rule
*/
public static void migrateDataTest(JenkinsRule jenkinsRule)
{
try
{
// Load and migrate the specified project from the test resource .zip file
TopLevelItem item = jenkinsRule.jenkins.getItem("TestProject");
assertDataMigrated(item);
}
catch (Exception e)
{
// Add the print of the stack trace because the exception message is not enough to troubleshoot the root issue. For
// example, if the exception is constructed without a message, you get no information from executing fail().
e.printStackTrace();
fail(e.getMessage());
}
}
示例2: migrateDataTest
import hudson.model.TopLevelItem; //导入依赖的package包/类
/**
* Perform a round trip migration test on the configuration.
* <p>
* An existing project is loaded, migrated, saved, and reloaded where the original configuration is compared against
* the reloaded configuration. The test project is loaded from a .zip file that mimics a Jenkins project's
* layout within.
*
* See test resource for the migration test: src/test/resources/com.compuware.jenkins.scm/<test>/<test method>.zip
*/
@Test
@LocalData
public void migrateDataTest()
{
try
{
// Load and migrate the specified project from the test resource .zip file
TopLevelItem item = m_jenkinsRule.jenkins.getItem("TestProject");
assertDataMigrated(item);
}
catch (Exception e)
{
// Add the print of the stack trace because the exception message is not enough to troubleshoot the root issue. For
// example, if the exception is constructed without a message, you get no information from executing fail().
e.printStackTrace();
fail(e.getMessage());
}
}
示例3: registerJobs
import hudson.model.TopLevelItem; //导入依赖的package包/类
private void registerJobs(UsageComputation uc) throws IOException, InterruptedException {
Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
throw new IllegalStateException("Jenkins has not been started, or was already shut down");
}
// Remove useless entries for jobs
for (JobDiskItem item : jobsUsages) {
if (!item.getPath().exists() || jenkins.getItemByFullName(item.getFullName(), Job.class) == null) {
jobsUsages.remove(item);
}
}
// Add or update entries for jobs
for (Job job : jenkins.getAllItems(Job.class)) {
if (job instanceof TopLevelItem) {
uc.addListener(job.getRootDir().toPath(), new JobUsageListener(job));
}
}
}
示例4: filter
import hudson.model.TopLevelItem; //导入依赖的package包/类
@Override
public List<TopLevelItem> filter(List<TopLevelItem> added, List<TopLevelItem> all, View filteringView) {
List<Pattern> patterns = getCompiled();
List<TopLevelItem> workList = added.isEmpty() ? all : added;
List<TopLevelItem> filtered = new LinkedList<TopLevelItem>();
for (TopLevelItem item : workList) {
if (item instanceof ParameterizedJobMixIn.ParameterizedJob) {
DockerHubTrigger trigger = DockerHubTrigger.getTrigger((ParameterizedJobMixIn.ParameterizedJob)item);
if (trigger != null) {
if (patterns.isEmpty()) {
filtered.add(item);
} else {
for (String name : trigger.getAllRepoNames()) {
if(matches(name)) {
filtered.add(item);
}
}
}
}
}
}
return filtered;
}
示例5: setUp
import hudson.model.TopLevelItem; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
items = new LinkedList<TopLevelItem>();
groups = new LinkedList<GitLabGroupInfo>();
// mock itemGroup#getGetItems() returning the items list
itemGroup = createMock(ModifiableTopLevelItemGroup.class);
expect(itemGroup.getItems()).andReturn(items).anyTimes();
// mock creating new GitLabFolderAuthorization folder properties
expectNewFolderAuthorization();
mockStatic(GitLab.class);
folderManager = new GroupFolderManager(this, itemGroup, folderDescriptor);
}
示例6: testGetItems
import hudson.model.TopLevelItem; //导入依赖的package包/类
@Test
public void testGetItems() throws Exception {
List<TopLevelItem> list = ImmutableList.of(mockItem, mockItem);
when(mockItemGroup.getItems()).thenReturn(list);
JobHistoryView underTest = new JobHistoryView() {
@Override
public ItemGroup getOwnerItemGroup() {
return mockItemGroup;
}
};
assertEquals(list, underTest.getItems());
verify(mockItemGroup, times(1)).getItems();
verifyNoMoreInteractions(mockItemGroup);
verifyNoMoreInteractions(mockItem);
}
示例7: testGetItems
import hudson.model.TopLevelItem; //导入依赖的package包/类
@Test
public void testGetItems() throws Exception {
List<TopLevelItem> list = ImmutableList.of(mockItem, mockItem);
when(mockItemGroup.getItems()).thenReturn(list);
LastProjectView underTest = new LastProjectView() {
@Override
public ItemGroup getOwnerItemGroup() {
return mockItemGroup;
}
};
assertEquals(0, underTest.getItems().size());
verifyNoMoreInteractions(mockItemGroup);
verifyNoMoreInteractions(mockItem);
}
示例8: submit
import hudson.model.TopLevelItem; //导入依赖的package包/类
public void submit(PrintStream log) throws IOException {
FreeStyleProject project = null;
TopLevelItem item = Jenkins.getActiveInstance().getItem(JobDslPluginJobSubmitter.UPDATE_JOB);
if (item != null && item instanceof FreeStyleProject) {
project = ((FreeStyleProject) item);
project.getBuildersList().clear();
project.save();
}
for (Job job : jobs) {
job.submit(log);
}
if (project != null) {
project.scheduleBuild(new MonitorTemplateJobs.TemplateTriggerCause());
log.println("Triggered " + project.getName());
}
}
示例9: initPython
import hudson.model.TopLevelItem; //导入依赖的package包/类
private void initPython() {
if (pexec == null) {
pexec = new PythonExecutor(this);
String[] jMethods = new String[1];
jMethods[0] = "locate";
String[] pFuncs = new String[1];
pFuncs[0] = "locate";
Class[][] argTypes = new Class[1][];
argTypes[0] = new Class[2];
argTypes[0][0] = TopLevelItem.class;
argTypes[0][1] = Node.class;
pexec.checkAbstrMethods(jMethods, pFuncs, argTypes);
String[] functions = new String[0];
int[] argsCount = new int[0];
pexec.registerFunctions(functions, argsCount);
}
}
示例10: doCreateItem
import hudson.model.TopLevelItem; //导入依赖的package包/类
@Override
public Item doCreateItem(StaplerRequest req, StaplerResponse rsp)
throws IOException, ServletException {
//First, we just create this item
Item item = null;
ItemGroup<? extends TopLevelItem> ig = getOwnerItemGroup();
if (ig instanceof ModifiableItemGroup)
item = ((ModifiableItemGroup<? extends TopLevelItem>)ig).doCreateItem(req, rsp);
//Checking if we deal with an inheritable job
if (item == null || !(item instanceof InheritanceProject)) {
return item;
}
//If we deal with an inheritable project, we assign it to the currently
//viewed creation class, if any
InheritanceProject ip = (InheritanceProject) item;
//Checking if we define a CC
if (!this.creationClassFilter.isEmpty()) {
ip.setCreationClass(this.creationClassFilter);
}
return item;
}
示例11: triggerManual
import hudson.model.TopLevelItem; //导入依赖的package包/类
@Override
public void triggerManual(AbstractProject<?, ?> project, AbstractProject<?, ?> upstream, String buildId,
ItemGroup<? extends TopLevelItem> itemGroup) throws TriggerException {
StandardBuildCard buildCard = new StandardBuildCard();
if (upstream != null && upstream.getBuild(buildId) != null) {
try {
buildCard.triggerManualBuild(itemGroup, Integer.parseInt(buildId),
project.getRelativeNameFrom(itemGroup),
upstream.getRelativeNameFrom(itemGroup));
} catch (Exception e) {
throw new TriggerException("Could not trigger", e);
}
} else {
throw new TriggerException("Could not find build: " + buildId + " for project: " + upstream);
}
}
示例12: testGetItemsAndContains
import hudson.model.TopLevelItem; //导入依赖的package包/类
@Test
public void testGetItemsAndContains() throws Exception {
final FreeStyleProject build = jenkins.createFreeStyleProject("build");
final FreeStyleProject sonar = jenkins.createFreeStyleProject("sonar");
final FreeStyleProject packaging = jenkins.createFreeStyleProject("packaging");
build.getPublishersList().add(new BuildTrigger("sonar", false));
build.getPublishersList().add(new BuildTrigger("packaging", false));
jenkins.getInstance().rebuildDependencyGraph();
List<DeliveryPipelineView.ComponentSpec> specs = new ArrayList<>();
specs.add(new DeliveryPipelineView.ComponentSpec("Comp", "build", NONE, DO_NOT_SHOW_UPSTREAM));
DeliveryPipelineView view = new DeliveryPipelineView("name");
view.setComponentSpecs(specs);
jenkins.getInstance().addView(view);
assertTrue(view.contains(build));
assertTrue(view.contains(sonar));
assertTrue(view.contains(packaging));
Collection<TopLevelItem> items = view.getItems();
assertEquals(3, items.size());
}
示例13: testGetItemsGetPipelinesWhenNoProjectFound
import hudson.model.TopLevelItem; //导入依赖的package包/类
@Test
public void testGetItemsGetPipelinesWhenNoProjectFound() throws Exception {
List<DeliveryPipelineView.ComponentSpec> specs = new ArrayList<>();
specs.add(new DeliveryPipelineView.ComponentSpec("Comp", "build", NONE, DO_NOT_SHOW_UPSTREAM));
DeliveryPipelineView view = new DeliveryPipelineView("name");
view.setComponentSpecs(specs);
jenkins.getInstance().addView(view);
Collection<TopLevelItem> items = view.getItems();
assertNotNull(items);
assertEquals(0, items.size());
List<Component> components = view.getPipelines();
assertNotNull(components);
assertTrue(components.isEmpty());
assertNotNull(view.getError());
}
示例14: testGetItemsAndContainsWithFolders
import hudson.model.TopLevelItem; //导入依赖的package包/类
@Test
public void testGetItemsAndContainsWithFolders() throws Exception {
MockFolder folder = jenkins.createFolder("folder");
final FreeStyleProject build = folder.createProject(FreeStyleProject.class, "build");
final FreeStyleProject sonar = folder.createProject(FreeStyleProject.class, "sonar");
final FreeStyleProject packaging = folder.createProject(FreeStyleProject.class, "packaging");
build.getPublishersList().add(new BuildTrigger("sonar", false));
build.getPublishersList().add(new BuildTrigger("packaging", false));
jenkins.getInstance().rebuildDependencyGraph();
List<DeliveryPipelineView.ComponentSpec> specs = new ArrayList<>();
specs.add(new DeliveryPipelineView.ComponentSpec("Comp", "build", NONE, DO_NOT_SHOW_UPSTREAM));
DeliveryPipelineView view = new DeliveryPipelineView("name");
view.setComponentSpecs(specs);
folder.addView(view);
assertTrue(view.contains(build));
assertTrue(view.contains(sonar));
assertTrue(view.contains(packaging));
Collection<TopLevelItem> items = view.getItems();
assertEquals(3, items.size());
}
示例15: testGetItems
import hudson.model.TopLevelItem; //导入依赖的package包/类
@Test
public void testGetItems() throws IOException {
final FreeStyleProject firstJob = jenkins.createFreeStyleProject("Project1");
final FreeStyleProject secondJob = jenkins.createFreeStyleProject("Project2");
final FreeStyleProject thirdJob = jenkins.createFreeStyleProject("Project3");
firstJob.getPublishersList().add((new BuildTrigger(secondJob.getName(), true)));
jenkins.getInstance().rebuildDependencyGraph();
DeliveryPipelineView pipeline = new DeliveryPipelineView("Pipeline");
List<DeliveryPipelineView.ComponentSpec> componentSpecs = new ArrayList<>();
componentSpecs.add(new DeliveryPipelineView.ComponentSpec("Spec", firstJob.getName(), NONE, DO_NOT_SHOW_UPSTREAM));
pipeline.setComponentSpecs(componentSpecs);
jenkins.getInstance().addView(pipeline);
Collection<TopLevelItem> jobs = pipeline.getItems();
assertTrue(jobs.contains(firstJob));
assertTrue(jobs.contains(secondJob));
assertFalse(jobs.contains(thirdJob));
}