Exemplo n.º 1
0
 public static List<AbstractProject<?, ?>> findProjectsWithEVMToolsBuilder(
     String... projectNames) {
   List<AbstractProject<?, ?>> returnList = new ArrayList<AbstractProject<?, ?>>();
   List<TopLevelItem> items = Jenkins.getInstance().getItems();
   for (TopLevelItem item : items) {
     if (item instanceof FreeStyleProject) {
       FreeStyleProject project = (FreeStyleProject) item;
       if (!project.isDisabled()) {
         DescribableList<Builder, Descriptor<Builder>> buildersList = project.getBuildersList();
         EVMToolsBuilder builder = buildersList.get(EVMToolsBuilder.class);
         if (builder != null) {
           if (projectNames.length != 0) {
             for (String projectName : projectNames) {
               if (project.getName().equals(projectName)) {
                 returnList.add(project);
                 break;
               }
             }
           } else {
             returnList.add(project);
           }
         }
       }
     }
   }
   return returnList;
 }
Exemplo n.º 2
0
 // ZD-13803
 @Bug(13803)
 @Test
 public void testDeleteJob() throws Exception {
   FreeStyleProject freeStyleProject = jenkins.createProject(FreeStyleProject.class, "test");
   freeStyleProject.save();
   SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
   System.out.println(
       "Before delete: "
           + sdf.format(new File(freeStyleProject.getRootDir(), "config.xml").lastModified()));
   freeStyleProject.delete();
   Thread.sleep(3 * 1000); // Give it a few seconds to create the file
   System.out.println(
       "After delete: "
           + sdf.format(new File(freeStyleProject.getRootDir(), "config.xml").lastModified()));
   assertFalse("Project should have been deleted", freeStyleProject.getRootDir().exists());
   Jenkins.getInstance().restart();
   Jenkins.getInstance().doReload();
   System.out.println(
       "After reload: "
           + sdf.format(new File(freeStyleProject.getRootDir(), "config.xml").lastModified()));
   assertFalse("Project should have been deleted", freeStyleProject.getRootDir().exists());
   assertFalse("Should not be disabled but instead deleted.", !freeStyleProject.isDisabled());
 }