Do you know if the "gradlew" task is somehow changing the PATH before it executes gradle?
In the docker gocd-agent, I can see that JAVA_HOME is not set, but java is available in /usr/bin. So, that shouldn't be a problem to run gradle. On Thu, Dec 7, 2017 at 3:15 PM, Aver <[email protected]> wrote: > I've been trying to debug this issue and noticed some interesting > behaviour. > > I've setup a pipeline with with 1 stage and following tasks: > > - pwd > - echo $JAVA_HOME > - java -version > - sh gradlew clean build > > The last task is the one that uses my gradle script to build the codes in > my repository. > > My initial configuration of the go-cd agent container looks like this (in > a docker compose file): > > version: '3.4' > > > services: > > gocd-agent: > > image: gocd/gocd-agent-centos-7:v17.11.0 > > restart: always > > environment: > > - GO_SERVER_URL=https://gocd-server:8154/go > > volumes: > > - /opt/gocd/data:/godata > > - /opt/gocd/home:/home/go > > > With this configuration the pipeline fails showing the JAVA_HOME error I > posted earlier. On the host machine where the go-cd agent container is > running, I have IBM JDK 8 installed. This is what I'd like to use with my > pipeline. > > So, if I change the docker compose like this and restart the agent with > this configuration, the pipeline is successfully completed. But, I can't > tell if it's really using IBM JDK or not. The 3rd task (java -version) > shows openjdk8, which is bundled with the container of the agent. > > version: '3.4' > > > services: > > gocd-agent: > > image: gocd/gocd-agent-centos-7:v17.11.0 > > restart: always > > environment: > > - GO_SERVER_URL=https://gocd-server:8154/go > > - JAVA_HOME=/opt/ibm/java-x86_64-80 > > volumes: > > - /opt/gocd/data:/godata > > - /opt/gocd/home:/home/go > > - /opt/ibm/java-x86_64-80:/opt/ibm/java-x86_64-80 > > I tried to use "GO_JAVA_HOME" environment variable in my docker compose > instead of "JAVA_HOME" (keeping same value). But that causes the pipeline > to fail with the same error about "JAVA_HOME" not being set, even though > the 3rd task (java -version) runs successfully and showing openjdk8. > > I'm not sure why my gradle script fails to run complaining about JAVA_HOME > not being defined even though "java -version" command runs successfully. If > I define JAVA_HOME in my docker compose file mounted to my IBM JDK > installation on the host machine, the pipeline runs. But, is it truly using > IBM JDK or Open JDK? How can I be sure? > > > > On Thursday, December 7, 2017 at 3:20:42 PM UTC-5, Aver wrote: >> >> Hi, >> >> I want to use dockerized go-cd server and agent. I have them both running >> on 2 separate hosts and the server can see the agent as well as run a >> pipeline successfully. I have some requirements that I'm not sure how to >> fit into this setup. >> >> Dockerized go-cd agent comes with openjdk8 pre-installed. I've setup a >> very simple pipeline that uses an internal git repository as it's material. >> The repository has a gradle script as well as gradle wrapper. In my >> pipeline, when setup a job to execute my gradle build script using the >> wrapper. But my pipeline fails with following error message: >> >> [go] Task: sh gradlew clean buildtook: 0.109sexited: 1 >> ERROR: JAVA_HOME is not set and no 'java' command could be found in your >> PATH. >> Please set the JAVA_HOME variable in your environment to match the >> location of your Java installation. >> [go] Task status: failed, took: 0.109s, exited: 1 >> >> >> I read through the entire page in Docker hub for the dockerized go-cd >> agent but didn't see anything that I might have missed. Has anyone used >> dockerized go-cd agent for running java? >> >> If I step into the container running go-cd agent, I can see java is >> available by running "java -version" but not sure why my pipeline is >> failing. >> >> >> >> >> -- > You received this message because you are subscribed to the Google Groups > "go-cd" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "go-cd" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
