protected int run() throws Exception { Jenkins h = Jenkins.getActiveInstance(); h.checkPermission(Jenkins.READ); // where is this build running? BuildIDs id = checkChannel().call(new BuildIDs()); if (!id.isComplete()) throw new IllegalStateException("This command can be only invoked from a build executing inside Hudson"); AbstractProject p = h.getItemByFullName(id.job, AbstractProject.class); if (p==null) throw new IllegalStateException("No such job found: "+id.job); p.checkPermission(Item.CONFIGURE); List<String> toolTypes = new ArrayList<>(); for (ToolDescriptor<?> d : ToolInstallation.all()) { toolTypes.add(d.getDisplayName()); if (d.getDisplayName().equals(toolType)) { List<String> toolNames = new ArrayList<>(); for (ToolInstallation t : d.getInstallations()) { toolNames.add(t.getName()); if (t.getName().equals(toolName)) return install(t, id, p); } // didn't find the right tool name error(toolNames, toolName, "name"); } } // didn't find the tool type error(toolTypes, toolType, "type"); // will never be here throw new AssertionError(); }
protected int run() throws Exception { Hudson h = Hudson.getInstance(); h.checkPermission(Hudson.READ); // where is this build running? BuildIDs id = channel.call(new BuildIDs()); if (!id.isComplete()) throw new AbortException("This command can be only invoked from a build executing inside Hudson"); AbstractProject p = Hudson.getInstance().getItemByFullName(id.job, AbstractProject.class); if (p==null) throw new AbortException("No such job found: "+id.job); p.checkPermission(Item.CONFIGURE); List<String> toolTypes = new ArrayList<String>(); for (ToolDescriptor<?> d : ToolInstallation.all()) { toolTypes.add(d.getDisplayName()); if (d.getDisplayName().equals(toolType)) { List<String> toolNames = new ArrayList<String>(); for (ToolInstallation t : d.getInstallations()) { toolNames.add(t.getName()); if (t.getName().equals(toolName)) return install(t, id, p); } // didn't find the right tool name error(toolNames, toolName, "name"); } } // didn't find the tool type error(toolTypes, toolType, "type"); // will never be here throw new AssertionError(); }
/** * Performs an installation. */ private int install(ToolInstallation t, BuildIDs id, AbstractProject p) throws IOException, InterruptedException { Run b = p.getBuildByNumber(Integer.parseInt(id.number)); if (b==null) throw new IllegalStateException("No such build: "+id.number); Executor exec = b.getExecutor(); if (exec==null) throw new IllegalStateException(b.getFullDisplayName()+" is not building"); Node node = exec.getOwner().getNode(); if (node == null) { throw new IllegalStateException("The node " + exec.getOwner().getDisplayName() + " has been deleted"); } t = t.translate(node, EnvVars.getRemote(checkChannel()), new StreamTaskListener(stderr)); stdout.println(t.getHome()); return 0; }
/** * Performs an installation. */ private int install(ToolInstallation t, BuildIDs id, AbstractProject p) throws IOException, InterruptedException { Run b = p.getBuildByNumber(Integer.parseInt(id.number)); if (b==null) throw new IllegalStateException("No such build: "+id.number); Executor exec = b.getExecutor(); if (exec==null) throw new IllegalStateException(b.getFullDisplayName()+" is not building"); Node node = exec.getOwner().getNode(); if (node == null) { throw new IllegalStateException("The node " + exec.getOwner().getDisplayName() + " has been deleted"); } t = t.translate(node, EnvVars.getRemote(checkChannel()), new StreamTaskListener(stderr)); stdout.println(t.getHome()); return 0; }
protected int run() throws Exception { Hudson h = Hudson.getInstance(); h.checkPermission(Hudson.READ); // where is this build running? BuildIDs id = channel.call(new BuildIDs()); if (!id.isComplete()) throw new AbortException("This command can be only invoked from a build executing inside Hudson"); AbstractProject p = Hudson.getInstance().getItemByFullName(id.job, AbstractProject.class); if (p==null) throw new AbortException("No such job found: "+id.job); p.checkPermission(Item.CONFIGURE); List<String> toolTypes = new ArrayList<String>(); for (ToolDescriptor<?> d : ToolInstallation.all()) { toolTypes.add(d.getDisplayName()); if (d.getDisplayName().equals(toolType)) { List<String> toolNames = new ArrayList<String>(); for (ToolInstallation t : d.getInstallations()) { toolNames.add(t.getName()); if (t.getName().equals(toolName)) return install(t, id, p); } // didn't find the right tool name error(toolNames, toolName, "name"); } } // didn't find the tool type error(toolTypes, toolType, "type"); // will never be here throw new AssertionError(); }
protected int run() throws Exception { Jenkins h = Jenkins.getActiveInstance(); h.checkPermission(Jenkins.READ); // where is this build running? BuildIDs id = checkChannel().call(new BuildIDs()); if (!id.isComplete()) throw new IllegalStateException("This command can be only invoked from a build executing inside Hudson"); AbstractProject p = h.getItemByFullName(id.job, AbstractProject.class); if (p==null) throw new IllegalStateException("No such job found: "+id.job); p.checkPermission(Item.CONFIGURE); List<String> toolTypes = new ArrayList<String>(); for (ToolDescriptor<?> d : ToolInstallation.all()) { toolTypes.add(d.getDisplayName()); if (d.getDisplayName().equals(toolType)) { List<String> toolNames = new ArrayList<String>(); for (ToolInstallation t : d.getInstallations()) { toolNames.add(t.getName()); if (t.getName().equals(toolName)) return install(t, id, p); } // didn't find the right tool name error(toolNames, toolName, "name"); } } // didn't find the tool type error(toolTypes, toolType, "type"); // will never be here throw new AssertionError(); }
protected int run() throws Exception { Hudson h = Hudson.getInstance(); h.checkPermission(Hudson.READ); // where is this build running? BuildIDs id = channel.call(new BuildIDs()); if (!id.isComplete()) throw new AbortException("This command can be only invoked from a build executing inside Hudson"); AbstractProject p = Hudson.getInstance().getItemByFullName(id.job, AbstractProject.class); if (p==null) throw new AbortException("No such job found: "+id.job); p.checkPermission(Item.CONFIGURE); List<String> toolTypes = new ArrayList<String>(); for (ToolDescriptor<?> d : ToolInstallation.all()) { toolTypes.add(d.getDisplayName()); if (d.getDisplayName().equals(toolType)) { List<String> toolNames = new ArrayList<String>(); for (ToolInstallation t : d.getInstallations()) { toolNames.add(t.getName()); if (t.getName().equals(toolName)) return install(t, id, p); } // didn't find the right tool name error(toolNames, toolName, "name"); } } // didn't find the tool type error(toolTypes, toolType, "type"); // will never be here throw new AssertionError(); }