Search in sources :

Example 1 with CommandExecutor

use of org.jfrog.build.extractor.executor.CommandExecutor 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 2 with CommandExecutor

use of org.jfrog.build.extractor.executor.CommandExecutor in project build-info by JFrogDev.

the class GitUtils method getGitLog.

public static CommandResults getGitLog(File execDir, Log logger, String previousVcsRevision, int limit) throws InterruptedException, IOException {
    List<String> args = new ArrayList<>();
    args.add("log");
    args.add("--pretty=format:%s");
    args.add("-" + (limit == 0 ? GIT_LOG_LIMIT : limit));
    if (!previousVcsRevision.isEmpty()) {
        args.add(previousVcsRevision + "..");
    }
    CommandExecutor commandExecutor = new CommandExecutor("git", null);
    return commandExecutor.exeCommand(execDir, args, null, logger);
}
Also used : ArrayList(java.util.ArrayList) CommandExecutor(org.jfrog.build.extractor.executor.CommandExecutor)

Example 3 with CommandExecutor

use of org.jfrog.build.extractor.executor.CommandExecutor in project build-info by JFrogDev.

the class DockerExtractorTest method execKaniko.

private String execKaniko(Path workingDirectory, String registry, Path kanikoConfigPath) throws IOException, InterruptedException {
    CommandExecutor commandExecutor = new CommandExecutor("docker", null);
    List<String> args = Lists.newArrayList("run", "--rm", "-v", workingDirectory.toAbsolutePath() + ":/workspace", "-v", kanikoConfigPath + ":/kaniko/.docker/config.json:ro", "gcr.io/kaniko-project/executor:latest", "--dockerfile=Dockerfile", "--destination=" + registry + "/hello-world", "--image-name-tag-with-digest-file=image-file");
    CommandResults results = commandExecutor.exeCommand(workingDirectory.toFile(), args, null, getLog());
    assertTrue(results.isOk(), results.getErr());
    return workingDirectory.resolve("image-file").toAbsolutePath().toString();
}
Also used : CommandExecutor(org.jfrog.build.extractor.executor.CommandExecutor) CommandResults(org.jfrog.build.extractor.executor.CommandResults)

Example 4 with CommandExecutor

use of org.jfrog.build.extractor.executor.CommandExecutor in project build-info by JFrogDev.

the class DockerExtractorTest method execJib.

private void execJib(Path workingDirectory) throws IOException, InterruptedException {
    CommandExecutor commandExecutor = new CommandExecutor("mvn", null);
    List<String> args = Lists.newArrayList("compile", "jib:build");
    CommandResults results = commandExecutor.exeCommand(workingDirectory.toFile(), args, null, getLog());
    assertTrue(results.isOk(), results.getErr());
}
Also used : CommandExecutor(org.jfrog.build.extractor.executor.CommandExecutor) CommandResults(org.jfrog.build.extractor.executor.CommandResults)

Example 5 with CommandExecutor

use of org.jfrog.build.extractor.executor.CommandExecutor in project build-info by JFrogDev.

the class GoExtractorTest method cleanGoModCacheAndEnv.

@BeforeMethod
private void cleanGoModCacheAndEnv() throws IOException, InterruptedException {
    CommandExecutor goCommandExecutor = new CommandExecutor("go", null);
    List<String> goCleanArgs = new ArrayList<>();
    goCleanArgs.add("clean");
    goCleanArgs.add("-modcache");
    goCommandExecutor.exeCommand(PROJECTS_ROOT.toFile(), goCleanArgs, null, log);
    env.clear();
    // Since we are handling dummy projects, we want to avoid package validation against Go's checksum DB.
    env.put("GONOSUMDB", "github.com/jfrog");
}
Also used : CommandExecutor(org.jfrog.build.extractor.executor.CommandExecutor) ArrayList(java.util.ArrayList) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

CommandExecutor (org.jfrog.build.extractor.executor.CommandExecutor)5 CommandResults (org.jfrog.build.extractor.executor.CommandResults)3 ArrayList (java.util.ArrayList)2 BeforeMethod (org.testng.annotations.BeforeMethod)1