/** * @deprecated Use {@link PreBuildMerge}. * @return pre-build merge options * @throws FormException on form error */ @Exported @Deprecated public PreBuildMergeOptions getMergeOptions() throws FormException { return DescriptorImpl.createMergeOptions(getUserMergeOptions(), remoteRepositories); }
private void updateFromUserData() throws GitException { // do what newInstance used to do directly from the request data if (userRemoteConfigs == null) { return; /* Prevent NPE when no remote config defined */ } try { String[] pUrls = new String[userRemoteConfigs.size()]; String[] repoNames = new String[userRemoteConfigs.size()]; String[] refSpecs = new String[userRemoteConfigs.size()]; for (int i = 0; i < userRemoteConfigs.size(); ++i) { pUrls[i] = userRemoteConfigs.get(i).getUrl(); repoNames[i] = userRemoteConfigs.get(i).getName(); refSpecs[i] = userRemoteConfigs.get(i).getRefspec(); } this.remoteRepositories = DescriptorImpl.createRepositoryConfigurations(pUrls, repoNames, refSpecs); // TODO: replace with new repositories } catch (IOException e1) { throw new GitException("Error creating repositories", e1); } }
/** * Fill in the environment variables for launching git * @param env base environment variables */ public void populateEnvironmentVariables(Map<String,String> env) { String name = getGlobalConfigName(); if (name!=null) { env.put("GIT_COMMITTER_NAME", name); env.put("GIT_AUTHOR_NAME", name); } String email = getGlobalConfigEmail(); if (email!=null) { env.put("GIT_COMMITTER_EMAIL", email); env.put("GIT_AUTHOR_EMAIL", email); } }
public SCM newInstance(StaplerRequest req, JSONObject formData) throws FormException { List<RemoteConfig> remoteRepositories; try { remoteRepositories = createRepositoryConfigurations(req.getParameterValues("git.repo.url"), req.getParameterValues("git.repo.name"), req.getParameterValues("git.repo.refspec"), throw new GitException(hudson.plugins.git.Messages.GitSCM_Repository_CreationExceptionMsg(), e1); List<BranchSpec> branches = createBranches(req.getParameterValues("git.branch")); PreBuildMergeOptions mergeOptions = createMergeOptions(req.getParameter("git.doMerge"), req.getParameter("git.mergeRemote"), req.getParameter("git.mergeTarget"), remoteRepositories); final GitRepositoryBrowser gitBrowser = getBrowserFromRequest(req, formData); String gitTool = req.getParameter("git.gitTool");
public SCM newInstance(StaplerRequest req, JSONObject formData) throws FormException { List<RemoteConfig> remoteRepositories; try { remoteRepositories = createRepositoryConfigurations(req.getParameterValues("git.repo.url"), req.getParameterValues("git.repo.name"), req.getParameterValues("git.repo.refspec")); throw new GitException("Error creating repositories", e1); List<BranchSpec> branches = createBranches(req.getParameterValues("git.branch")); PreBuildMergeOptions mergeOptions = createMergeOptions(req.getParameter("git.doMerge"), req.getParameter("git.mergeRemote"), req.getParameter("git.mergeTarget"), remoteRepositories); Collection<SubmoduleConfig> submoduleCfg = new ArrayList<SubmoduleConfig>(); final GitRepositoryBrowser gitBrowser = getBrowserFromRequest(req, formData); String gitTool = req.getParameter("git.gitTool"); return new GitSCM(
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 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(); }
@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"); } }
/** * A convenience constructor that sets everything to default. * * @param repositoryUrl Repository URL to clone from. * @throws java.io.IOException exception. */ public GitSCM(String repositoryUrl) throws IOException { this( DescriptorImpl.createRepositoryConfigurations(new String[]{repositoryUrl}, new String[]{null}, new String[]{null}), Collections.singletonList(new BranchSpec("")), new PreBuildMergeOptions(), false, Collections.<SubmoduleConfig>emptyList(), false, false, new DefaultBuildChooser(), null, null, false, null, null, null, null, false, false, null, null, false); }
/** * A convenience constructor that sets everything to default. * * @param repositoryUrl Repository URL to clone from. * @throws java.io.IOException exception. */ public GitSCM(String repositoryUrl) throws IOException, Descriptor.FormException { this( DescriptorImpl.createRepositoryConfigurations(new String[]{repositoryUrl}, new String[]{null}, new String[]{null}), Collections.singletonList(new BranchSpec("")), new PreBuildMergeOptions(), false, Collections.<SubmoduleConfig>emptyList(), false, false, new DefaultBuildChooser(), null, null, false, null, null, null, false, false, false, null, null, false, null, false); }
public DescriptorImpl() { super(GitSCM.class, GitRepositoryBrowser.class); load(); }
public static List<RemoteConfig> createRepositoryConfigurations(String[] pUrls, String[] repoNames, String[] refSpecs) throws IOException { File temp = File.createTempFile("tmp", "config"); try { return createRepositoryConfigurations(pUrls, repoNames, refSpecs, temp); } finally { temp.delete(); } }
@Override public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { req.bindJSON(this, formData); save(); return true; }
public String getGitConfigNameToUse() { String confName; String globalConfigName = ((DescriptorImpl) getDescriptor()).getGlobalConfigName(); if ((globalConfigName != null) && (gitConfigName == null) && (!fixEmptyAndTrim(globalConfigName).equals(""))) { confName = globalConfigName; } else { confName = gitConfigName; } return fixEmptyAndTrim(confName); }
public DescriptorImpl() { super(GitSCM.class, GitRepositoryBrowser.class); load(); }
/** * {@inheritDoc} */ @Override public GitClient decorate(GitSCM scm, GitClient git) throws IOException, InterruptedException, GitException { GitSCM.DescriptorImpl d = scm.getDescriptor(); String n = d.getGlobalConfigName(); if (name!=null) n = name; String e = d.getGlobalConfigEmail(); if (email!=null) e = email; git.setAuthor(n,e); git.setCommitter(n,e); return git; }
@Override public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { req.bindJSON(this, formData); save(); return true; }
@Override public boolean configure(StaplerRequest req, JSONObject formData) throws Descriptor.FormException { req.bindJSON(this, formData); save(); return true; }
public String getGitConfigEmailToUse() { String confEmail; String globalConfigEmail = ((DescriptorImpl) getDescriptor()).getGlobalConfigEmail(); if ((globalConfigEmail != null) && (gitConfigEmail == null) && (!fixEmptyAndTrim(globalConfigEmail).equals( ""))) { confEmail = globalConfigEmail; } else { confEmail = gitConfigEmail; } return fixEmptyAndTrim(confEmail); }
public DescriptorImpl() { super(GitSCM.class, GitRepositoryBrowser.class); beforeLoad(); load(); }