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.

  • Jenkins build inside a docker container with generated reports
  • AWS EC2 - connection refused running docker container
  • error : curl: (52) Empty reply from server , when ingesting data into druid
  • Docker link between varnish and wordpress not working
  • Running Gatling from container
  • Is it possible to run linux docker image on windows
  • Is there a way of passing the envs into the gradle build parameter or should the above be sufficient?

  • how can i dynamically create a docker container from a node application
  • container is in waiting state, kubernetes, docker container
  • Docker and HttpCallback
  • How can I delete Docker images by tag, preferably with wildcarding?
  • Docker push - net/http: TLS handshake timeout
  • Verbose logging in Kubernetes deployment file
  • 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
    
    BUILD SUCCESSFUL
    
    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.