Search in sources :

Example 1 with ToolInstallation

use of hudson.tools.ToolInstallation in project hudson-2.x by hudson.

the class InstallToolCommand method run.

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();
}
Also used : Hudson(hudson.model.Hudson) ArrayList(java.util.ArrayList) ToolInstallation(hudson.tools.ToolInstallation) AbstractProject(hudson.model.AbstractProject) AbortException(hudson.AbortException)

Aggregations

AbortException (hudson.AbortException)1 AbstractProject (hudson.model.AbstractProject)1 Hudson (hudson.model.Hudson)1 ToolInstallation (hudson.tools.ToolInstallation)1 ArrayList (java.util.ArrayList)1