/** * Lists available toolinstallations. * @return list of available git tools */ @SuppressFBWarnings(value="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification="Jenkins.getInstance() is not null") public List<GitTool> getGitTools() { GitTool[] gitToolInstallations = Jenkins.getInstance().getDescriptorByType(GitTool.DescriptorImpl.class).getInstallations(); return Arrays.asList(gitToolInstallations); }
public GitTool getInstallation(String name) { for(GitTool i : getInstallations()) { if(i.getName().equals(name)) { return i; } } return null; }
/** * Exposing so that we can get this from GitPublisher. * * @param builtOn {@link Node}. * @param listener {@link TaskListener}. */ public String getGitExe(Node builtOn, TaskListener listener) { GitTool[] gitToolInstallations = Hudson.getInstance() .getDescriptorByType(GitTool.DescriptorImpl.class) .getInstallations(); for (GitTool t : gitToolInstallations) { //If gitTool is null, use first one. if (gitTool == null) { gitTool = t.getName(); } if (t.getName().equals(gitTool) && builtOn != null) { try { String s = t.forNode(builtOn, listener).getGitExe(); return s; } catch (IOException e) { listener.getLogger().println("Failed to get git executable"); } catch (InterruptedException e) { listener.getLogger().println("Failed to get git executable"); } } } return null; }
GitTool[] installations = ((hudson.plugins.git.GitTool.DescriptorImpl)Hudson.getInstance().getDescriptorByType(GitTool.DescriptorImpl.class)).getInstallations(); for(GitTool i : installations) { if(i.getName().equals(gitTool)) {
/** * Exposing so that we can get this from GitPublisher. * * @param builtOn {@link Node}. * @param listener {@link TaskListener}. */ public String getGitExe(Node builtOn, TaskListener listener) { GitTool[] gitToolInstallations = Hudson.getInstance() .getDescriptorByType(GitTool.DescriptorImpl.class) .getInstallations(); for (GitTool t : gitToolInstallations) { //If gitTool is null, use first one. if (gitTool == null) { gitTool = t.getName(); } if (t.getName().equals(gitTool) && builtOn != null) { try { String s = t.forNode(builtOn, listener).getGitExe(); return s; } catch (IOException e) { listener.getLogger().println("Failed to get git executable"); } catch (InterruptedException e) { listener.getLogger().println("Failed to get git executable"); } } } return null; }
/** * Returns the default installation. * * @return default installation */ public static GitTool getDefaultInstallation() { Jenkins jenkinsInstance = Jenkins.getInstance(); DescriptorImpl gitTools = jenkinsInstance.getDescriptorByType(GitTool.DescriptorImpl.class); GitTool tool = gitTools.getInstallation(GitTool.DEFAULT); if (tool != null) { return tool; } else { GitTool[] installations = gitTools.getInstallations(); if (installations.length > 0) { return installations[0]; } else { onLoaded(); return gitTools.getInstallations()[0]; } } }
@SuppressFBWarnings(value="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification="Jenkins.getInstance() is not null") public boolean showGitToolOptions() { return Jenkins.getInstance().getDescriptorByType(GitTool.DescriptorImpl.class).getInstallations().length>1; }
private static GitTool[] getInstallations(DescriptorImpl descriptor) { GitTool[] installations = null; try { installations = descriptor.getInstallations(); } catch (NullPointerException e) { installations = new GitTool[0]; } return installations; }
private static GitTool[] getInstallations(DescriptorImpl descriptor) { GitTool[] installations; try { installations = descriptor.getInstallations(); } catch (NullPointerException e) { installations = new GitTool[0]; } return installations; }
/** * Lists available toolinstallations. * * @return list of available git tools */ public List<GitTool> getGitTools() { GitTool[] gitToolInstallations = Hudson.getInstance() .getDescriptorByType(GitTool.DescriptorImpl.class) .getInstallations(); return Arrays.asList(gitToolInstallations); }
private static GitTool[] getInstallations(DescriptorImpl descriptor) { GitTool[] installations = null; try { installations = descriptor.getInstallations(); } catch (NullPointerException e) { installations = new GitTool[0]; } return installations; }
/** * Lists available toolinstallations. * * @return list of available git tools */ public List<GitTool> getGitTools() { GitTool[] gitToolInstallations = Hudson.getInstance() .getDescriptorByType(GitTool.DescriptorImpl.class) .getInstallations(); return Arrays.asList(gitToolInstallations); }