use of org.jfrog.build.extractor.executor.CommandResults in project build-info by JFrogDev.
the class NpmDriver method configList.
public String configList(File workingDirectory, List<String> extraArgs, Log logger) throws IOException, InterruptedException {
List<String> args = new ArrayList<>(extraArgs);
args.add("--json=false");
CommandResults res = runCommand(workingDirectory, new String[] { "c", "ls" }, args);
if (logger != null && StringUtils.isNotBlank(res.getErr())) {
logger.warn(res.getErr());
}
return res.getRes();
}
use of org.jfrog.build.extractor.executor.CommandResults in project build-info by JFrogDev.
the class NpmDriver method runCommand.
private CommandResults runCommand(File workingDirectory, String[] args, List<String> extraArgs, Log logger) throws IOException, InterruptedException {
List<String> finalArgs = Stream.concat(Arrays.stream(args), extraArgs.stream()).collect(Collectors.toList());
CommandResults npmCommandRes = commandExecutor.exeCommand(workingDirectory, finalArgs, null, logger);
if (!npmCommandRes.isOk()) {
throw new IOException(npmCommandRes.getErr() + npmCommandRes.getRes());
}
return npmCommandRes;
}
use of org.jfrog.build.extractor.executor.CommandResults in project build-info by JFrogDev.
the class GitUtilsTest method getGitFieldWithExecutor.
private String getGitFieldWithExecutor(File execDir, Log log, List<String> args) throws IOException, InterruptedException {
CommandExecutor executor = new CommandExecutor("git", null);
CommandResults res = executor.exeCommand(execDir, args, null, log);
Assert.assertTrue(res.isOk());
return res.getRes().trim();
}
use of org.jfrog.build.extractor.executor.CommandResults in project build-info by JFrogDev.
the class ToolchainDriverBase method runCommand.
/**
* Run .NET/Nuget command.
*
* @param args - Base args, such as "nuget add source source-url"
* @param extraArgs - Extra args, such as "--config=config-path --name=source-name"
* @param credentials - Credentials, such as "--username=username --password=password"
* @param logger - The logger of the command
* @return the output.
* @throws IOException if the command execution returned an error.
* @throws InterruptedException if the command execution interrupted.
*/
protected String runCommand(String[] args, List<String> extraArgs, List<String> credentials, Log logger) throws IOException, InterruptedException {
List<String> finalArgs = Stream.concat(Arrays.stream(args), extraArgs.stream()).collect(Collectors.toList());
CommandResults nugetCommandRes = commandExecutor.exeCommand(workingDirectory, finalArgs, credentials, logger);
if (!nugetCommandRes.isOk()) {
throw new IOException(nugetCommandRes.getErr() + nugetCommandRes.getRes());
}
return nugetCommandRes.getErr() + nugetCommandRes.getRes();
}
use of org.jfrog.build.extractor.executor.CommandResults in project build-info by JFrogDev.
the class GitUtils method extractVcsMessage.
private static String extractVcsMessage(File dotGit, Log log) {
String warnMessage = "Failed fetching commit message from git directory: " + dotGit + "\nWith the following error: ";
try {
CommandResults res = getGitLog(dotGit, log, 1);
if (res.isOk()) {
return res.getRes().trim();
}
log.warn(warnMessage + res.getErr());
} catch (InterruptedException | IOException e) {
log.warn(warnMessage + e.getMessage());
}
return "";
}
Aggregations