@Override public void postInitialize() throws IOException { GitTool.onLoaded(); } }
public GitTool forNode(Node node, TaskListener log) throws IOException, InterruptedException { return new GitTool(getName(), translateFor(node, log), Collections.<ToolProperty<?>>emptyList()); }
/** * 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; }
@Initializer(after=EXTENSIONS_AUGMENTED) public static void onLoaded() { //Creates default tool installation if needed. Uses "git" or migrates data from previous versions Jenkins jenkinsInstance = Jenkins.getInstance(); DescriptorImpl descriptor = (DescriptorImpl) jenkinsInstance.getDescriptor(GitTool.class); GitTool[] installations = getInstallations(descriptor); if (installations != null && installations.length > 0) { //No need to initialize if there's already something return; } String defaultGitExe = isWindows() ? "git.exe" : "git"; GitTool tool = new GitTool(DEFAULT, defaultGitExe, Collections.<ToolProperty<?>>emptyList()); descriptor.setInstallations(new GitTool[] { tool }); descriptor.save(); }
/** * Exposing so that we can get this from GitPublisher. * @param builtOn node where build was performed * @param env environment variables used in the build * @param listener build log * @return git exe for builtOn node, often "Default" or "jgit" */ public String getGitExe(Node builtOn, EnvVars env, TaskListener listener) { GitClientType client = GitClientType.ANY; for (GitSCMExtension ext : extensions) { try { client = client.combine(ext.getRequiredClient()); } catch (GitClientConflictException e) { throw new RuntimeException(ext.getDescriptor().getDisplayName() + " extended Git behavior is incompatible with other behaviors"); } } if (client == GitClientType.JGIT) return JGitTool.MAGIC_EXENAME; GitTool tool = resolveGitTool(listener); if (builtOn != null) { try { tool = tool.forNode(builtOn, listener); } catch (IOException | InterruptedException e) { listener.getLogger().println("Failed to get git executable"); } } if (env != null) { tool = tool.forEnvironment(env); } return tool.getGitExe(); }
public static void onLoaded() { //Creates default tool installation if needed. Uses "git" or migrates data from previous versions DescriptorImpl descriptor = (DescriptorImpl) Hudson.getInstance().getDescriptor(GitTool.class); GitTool[] installations = getInstallations(descriptor); if (installations.length > 0) { //No need to initialize if there's already something return; } DescriptorExtensionList<SCM, SCMDescriptor<?>> scms = GitSCM.all(); String defaultGitExe = File.separatorChar != '/' ? "git.exe" : "git"; for (SCMDescriptor<?> s : scms) { if (s instanceof GitSCM.DescriptorImpl) { //Get previous settings from descriptor GitSCM.DescriptorImpl desc = (GitSCM.DescriptorImpl) s; if (desc.getOldGitExe() != null) { defaultGitExe = desc.getOldGitExe(); } } } GitTool tool = new GitTool(defaultValueName, defaultGitExe, Collections.<ToolProperty<?>>emptyList()); descriptor.setInstallations(new GitTool[]{tool}); descriptor.save(); }
public GitTool getInstallation(String name) { for(GitTool i : getInstallations()) { if(i.getName().equals(name)) { return i; } } return null; }
@Initializer(after=PLUGINS_STARTED) public static void onLoaded() { Jenkins jenkins = Jenkins.getInstance(); if (jenkins == null) { LOGGER.severe("Jenkins.getInstance is null in GitSCM.onLoaded"); return; } DescriptorImpl desc = jenkins.getDescriptorByType(DescriptorImpl.class); if (desc.getOldGitExe() != null) { String exe = desc.getOldGitExe(); String defaultGit = GitTool.getDefaultInstallation().getGitExe(); if (exe.equals(defaultGit)) { return; } System.err.println("[WARNING] you're using deprecated gitexe attribute to configure git plugin. Use Git installations"); } }
/** * getGitExe. * * @return {@link java.lang.String} that will be used to execute git (e.g. "git" or "/usr/bin/git") */ public String getGitExe() { return getHome(); }
GitTool tool = gitSCMSource.resolveGitTool(builder.gitTool()); if (tool != null) { git.using(tool.getGitExe());
/** * 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; }
public static void onLoaded() { //Creates default tool installation if needed. Uses "git" or migrates data from previous versions DescriptorImpl descriptor = (DescriptorImpl) Hudson.getInstance().getDescriptor(GitTool.class); GitTool[] installations = getInstallations(descriptor); if (installations.length > 0) { //No need to initialize if there's already something return; } DescriptorExtensionList<SCM, SCMDescriptor<?>> scms = GitSCM.all(); String defaultGitExe = File.separatorChar != '/' ? "git.exe" : "git"; for (SCMDescriptor<?> s : scms) { if (s instanceof GitSCM.DescriptorImpl) { //Get previous settings from descriptor GitSCM.DescriptorImpl desc = (GitSCM.DescriptorImpl) s; if (desc.getOldGitExe() != null) { defaultGitExe = desc.getOldGitExe(); } } } GitTool tool = new GitTool(defaultValueName, defaultGitExe, Collections.<ToolProperty<?>>emptyList()); descriptor.setInstallations(new GitTool[]{tool}); descriptor.save(); }
public ListBoxModel doFillGitToolItems() { ListBoxModel r = new ListBoxModel(); for (GitTool git : getGitTools()) { r.add(git.getName()); } return r; }
.using(GitTool.getDefaultInstallation().getGitExe()) .getClient(); StandardCredentials credential = lookupCredentials(item, credentialsId, url);
public String getGitExe() { return getHome(); }
GitTool tool = resolveGitTool(context.gitTool()); if (tool != null) { git.using(tool.getGitExe());
public GitTool forNode(Node node, TaskListener log) throws IOException, InterruptedException { return new GitTool(getName(), translateFor(node, log), Collections.<ToolProperty<?>>emptyList()); }