Suppressing interactive output in Gradle exec tasks

Some Gradle Exec tasks produce excessive output when the command updates text in place.

When run from a terminal, these commands produce a couple of lines of output that are updated in place.

  • Is it possible to start a shell session in a running container (without ssh)
  • I'm attempting to connect to MongoDB with a Clojure application, via Docker
  • docker-py getarchive destination folder
  • Unable to see non-Latin filename in manually created host volume
  • Cannot validate certificate for ip because it doesn't contain any IP SANs
  • Docker Registry 2.0 enable CORS
  • When run from within Gradle, they produce a new line of output each time something is updated, e.g.:

    docker build:

    task dockerBuild(type: Exec) {
        commandLine 'docker', 'build', '-t', 'foo', '.'
    }
    

    when run produces:

    Sending build context to Docker daemon 557.1 kB
    Sending build context to Docker daemon 1.114 MB
    Sending build context to Docker daemon 1.646 MB
    Sending build context to Docker daemon  2.17 MB
    Sending build context to Docker daemon  2.72 MB
    Sending build context to Docker daemon 3.277 MB
    Sending build context to Docker daemon 3.834 MB
    Sending build context to Docker daemon 4.391 MB
    ... hundreds more lines ...
    

    wget:

    task fetchData(type: Exec) {
        commandLine 'wget', 'http://example.org/some/large/file'
    }
    

    when run outputs:

    HTTP request sent, awaiting response... 200 OK
    Length: 209715200 (200M) [application/zip]
    Saving to: '200MB.zip'
    
      0K .......... .......... .......... .......... ..........  0% 5.02M 40s
     50K .......... .......... .......... .......... ..........  0% 6.34M 36s
    100K .......... .......... .......... .......... ..........  0% 6.68M 34s
    150K .......... .......... .......... .......... ..........  0% 6.42M 33s
    200K .......... .......... .......... .......... ..........  0% 6.41M 33s
    250K .......... .......... .......... .......... ..........  0% 7.12M 32s
    ... thousands more lines ...
    

    Is this anything I can fix from within Gradle (e.g. ask it to execute commands in non-interactive mode), or is it down to individual applications to provide flags for disabling this sort of output?

  • Get hostname in Logstash running in a Docker container
  • Add external plugin to sonarqube
  • Non-root user in Docker
  • cron on a docker container for laravel not working
  • Update docker image resulting in orphan image
  • Docker proxy windows daemon named pipe to Ubuntu Container
  • One Solution collect form web for “Suppressing interactive output in Gradle exec tasks”

    From Exec DSL documentation, you can redirect the output of the executable to your own stream.

    //store the output instead of printing to the console:
    standardOutput = new ByteArrayOutputStream()
    

    You could optionally also redirect error stream to keep it completely quiet, but by leaving it intact, you’ll see any exit errors in gradle log.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.