From fdc2d02af68211c1450b47cef065e97f4126c338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20August=C3=BDn?= Date: Wed, 9 Aug 2023 00:02:01 +0200 Subject: [PATCH] also error output read from containers --- .../com/avast/gradle/dockercompose/ComposeExecutor.groovy | 2 +- .../com/avast/gradle/dockercompose/DockerExecutor.groovy | 1 + .../avast/gradle/dockercompose/DockerExecutorTest.groovy | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/groovy/com/avast/gradle/dockercompose/ComposeExecutor.groovy b/src/main/groovy/com/avast/gradle/dockercompose/ComposeExecutor.groovy index 9b179bb4..2e37c00c 100644 --- a/src/main/groovy/com/avast/gradle/dockercompose/ComposeExecutor.groovy +++ b/src/main/groovy/com/avast/gradle/dockercompose/ComposeExecutor.groovy @@ -138,7 +138,7 @@ abstract class ComposeExecutor implements BuildService, AutoCloseabl } Map> getContainerIds(List serviceNames) { - // `docker-compose ps -q serviceName` returns an exit code of 1 when the service + // `docker compose ps -q serviceName` returns an exit code of 1 when the service // doesn't exist. To guard against this, check the service list first. def services = execute('ps', '--services').readLines() def result = [:] diff --git a/src/main/groovy/com/avast/gradle/dockercompose/DockerExecutor.groovy b/src/main/groovy/com/avast/gradle/dockercompose/DockerExecutor.groovy index f01786de..53be6c16 100644 --- a/src/main/groovy/com/avast/gradle/dockercompose/DockerExecutor.groovy +++ b/src/main/groovy/com/avast/gradle/dockercompose/DockerExecutor.groovy @@ -29,6 +29,7 @@ class DockerExecutor { def finalArgs = [settings.dockerExecutable.get()] finalArgs.addAll(args) e.commandLine finalArgs + e.errorOutput = os e.standardOutput = os e.ignoreExitValue = true } diff --git a/src/test/groovy/com/avast/gradle/dockercompose/DockerExecutorTest.groovy b/src/test/groovy/com/avast/gradle/dockercompose/DockerExecutorTest.groovy index facbde41..152859d0 100644 --- a/src/test/groovy/com/avast/gradle/dockercompose/DockerExecutorTest.groovy +++ b/src/test/groovy/com/avast/gradle/dockercompose/DockerExecutorTest.groovy @@ -30,14 +30,14 @@ class DockerExecutorTest extends Specification { } def "reads container logs"() { - def f = Fixture.withHelloWorld() + def f = Fixture.withNginx() f.project.tasks.composeBuild.build() f.project.tasks.composeUp.up() - String containerId = f.extension.servicesInfos.hello.firstContainer.containerId + String containerId = f.extension.servicesInfos.web.firstContainer.containerId when: String output = f.extension.dockerExecutor.getContainerLogs(containerId) then: - output.contains('Hello from Docker') + output.contains('nginx') cleanup: f.project.tasks.composeDown.down() f.close()