/** * Launch command using the workspace as working directory * * @param args arguments to the command * @return command output * @throws hudson.plugins.git.GitException if launched command fails * @throws java.lang.InterruptedException if interrupted */ public String launchCommand(ArgumentListBuilder args) throws GitException, InterruptedException { return launchCommandIn(args, workspace); }
private String launchCommandIn(ArgumentListBuilder args, File workDir) throws GitException, InterruptedException { return launchCommandIn(args, workDir, environment); }
private String launchCommandIn(ArgumentListBuilder args, File workDir, EnvVars env) throws GitException, InterruptedException { return launchCommandIn(args, workDir, environment, TIMEOUT); }
/** {@inheritDoc} */ public Set<String> getTagNames(String tagPattern) throws GitException { try { ArgumentListBuilder args = new ArgumentListBuilder(); args.add("tag", "-l", tagPattern); String result = launchCommandIn(args, workspace); Set<String> tags = new HashSet<>(); BufferedReader rdr = new BufferedReader(new StringReader(result)); String tag; while ((tag = rdr.readLine()) != null) { // Add the SHA1 tags.add(tag); } return tags; } catch (Exception e) { throw new GitException("Error retrieving tag names", e); } }
String result; try { result = launchCommandIn(args, workspace); } catch (GitException ge) {
/** {@inheritDoc} */ public Set<String> getRemoteTagNames(String tagPattern) throws GitException { try { ArgumentListBuilder args = new ArgumentListBuilder(); args.add("ls-remote", "--tags"); args.add(getRemoteUrl("origin")); if (tagPattern != null) args.add(tagPattern); String result = launchCommandIn(args, workspace); Set<String> tags = new HashSet<>(); BufferedReader rdr = new BufferedReader(new StringReader(result)); String tag; while ((tag = rdr.readLine()) != null) { // Add the tag name without the SHA1 tags.add(tag.replaceFirst(".*refs/tags/", "")); } return tags; } catch (Exception e) { throw new GitException("Error retrieving remote tag names", e); } }
return launchCommandIn(args, workDir, env, timeout); } catch (IOException e) { throw new GitException("Failed to setup credentials", e);