Search in sources :

Example 1 with CommandResults

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();
}
Also used : CommandResults(org.jfrog.build.extractor.executor.CommandResults)

Example 2 with CommandResults

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;
}
Also used : IOException(java.io.IOException) CommandResults(org.jfrog.build.extractor.executor.CommandResults)

Example 3 with CommandResults

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();
}
Also used : CommandExecutor(org.jfrog.build.extractor.executor.CommandExecutor) CommandResults(org.jfrog.build.extractor.executor.CommandResults)

Example 4 with CommandResults

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();
}
Also used : IOException(java.io.IOException) CommandResults(org.jfrog.build.extractor.executor.CommandResults)

Example 5 with CommandResults

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 "";
}
Also used : IOException(java.io.IOException) CommandResults(org.jfrog.build.extractor.executor.CommandResults)

Aggregations

CommandResults (org.jfrog.build.extractor.executor.CommandResults)10 IOException (java.io.IOException)5 CommandExecutor (org.jfrog.build.extractor.executor.CommandExecutor)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 File (java.io.File)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 ExceptionUtils (org.apache.commons.lang3.exception.ExceptionUtils)1 Log (org.jfrog.build.api.util.Log)1 NullLog (org.jfrog.build.api.util.NullLog)1 GoDriver (org.jfrog.build.extractor.go.GoDriver)1 DependencyTree (org.jfrog.build.extractor.scan.DependencyTree)1 Test (org.testng.annotations.Test)1