@Test public void loadJenkinsWorkSpaceWithNestedViews() throws Exception { Mockito.when(securityClientMock.execute(Mockito.any(URL.class))) .thenReturn( IOUtils.toString( JenkinsRequestManagerTest.class.getResourceAsStream( "JenkinsRequestManager_loadJenkinsWorkspaceWithNestedView.xml"))); Jenkins jenkins = requestManager.loadJenkinsWorkspace(configuration); List<View> actualViews = jenkins.getViews(); List<View> expectedViews = new LinkedList<View>(); expectedViews.add(View.createView("Framework", "http://myjenkins/view/Framework/")); View nestedView = View.createView("NestedView", "http://myjenkins/view/NestedView/"); nestedView.addSubView( View.createNestedView( "FirstSubView", "http://myjenkins/view/NestedView/view/FirstSubView/")); nestedView.addSubView( View.createNestedView( "SecondSubView", "http://myjenkins/view/NestedView/view/SecondSubView/")); expectedViews.add(nestedView); expectedViews.add(View.createView("Tous", "http://myjenkins/")); assertReflectionEquals(expectedViews, actualViews); assertReflectionEquals(View.createView("Tous", "http://myjenkins"), jenkins.getPrimaryView()); }
/** * Returns the directory that the nodes are stored in. * * @return the directory that the nodes are stored in. * @throws IOException */ private File getNodesDir() throws IOException { final File nodesDir = new File(jenkins.getRootDir(), "nodes"); if (!nodesDir.isDirectory() && !nodesDir.mkdirs()) { throw new IOException(String.format("Could not mkdirs %s", nodesDir)); } return nodesDir; }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { try { for (JSONObject o : StructuredForm.toList(json, "plugin")) Jenkins.getInstance() .pluginManager .getPlugin(o.getString("name")) .getPlugin() .configure(req, o); return true; } catch (IOException | ServletException e) { throw new FormException(e, "plugin"); } }
/** * Returns {@code true} if and only if the list of nodes is stored in the legacy location. * * @return {@code true} if and only if the list of nodes is stored in the legacy location. */ public boolean isLegacy() { return !new File(jenkins.getRootDir(), "nodes").isDirectory(); }
public String getCommand() { return RunIdMigrator.getUnmigrationCommandLine(Jenkins.getInstance().getRootDir()); }
@Override public Object getTarget() { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); return this; }