Passing envs into gradle build?

I am using gradlew within a container for a CI build.

ENV values are not being recognized when I add them in the bash shell.

  • Cannot connect to MySQL docker container from container with Django app
  • How do I create a file within “docker run”
  • Different servers generate different JWT tokens using the same parameters
  • Failed to remove docker images whose tag are <none>
  • Access private docker registry in browser
  • Launch service at container startup
  • Is there a way of passing the envs into the gradle build parameter or should the above be sufficient?

  • What is the best way to append to /etc/hosts within Dockerfile
  • What's the difference between Kubernetes and Flynn/Deis
  • docker-compose.yml vs docker-stack.yml what difference?
  • Docker maven plugin NullPointerException
  • docker how to commit but exclude directory from image
  • Docker command fails during build, but succeeds while executed within running container
  • One Solution collect form web for “Passing envs into gradle build?”

    I’m not really sure about the problem here, is that you cannot read the variables inside gradle?

    This question might help: In Gradle, is there a better way to get Environment Variables?

    version = System.getenv("JENKINS_BUILD_NUMBER") ?: "0.1-SNAPSHOT"

    is working fine in my build.gradle scripts.

    Here there is an example:

    Well, that should definitely work fine.

    that’s my build.gradle:

    apply plugin: 'java'
    apply plugin: 'groovy'
    task('hello') {
      println System.getenv("HI")

    So, if I run:

    export HI="hello there"

    gradle hello

    I get this:

    hello there
    :hello UP-TO-DATE
    Total time: 0.869 secs

    This works. Just make sure that the ENV variables are correctly defined in your CI conf.

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