maven job is run with wrong java version

2,034 views
Skip to first unread message

Soren Cito

unread,
Dec 18, 2014, 3:28:48 AM12/18/14
to go...@googlegroups.com
Hi,

I'm trying to get a simple Maven 3 build running under windows. My build works fine running from the console, but when I let Go build it, it uses the wrong Java version.

[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message: Detected JDK Version: 1.7.0-9 is not in the allowed range [1.8,).

I have set my JAVA_HOME set accordingly, in both, user and system properties. I have controlled the PATH many times and can't find any reference to a JDK 1.7. I also deleted the preinstalled Java from c:\windows.

Interestinlgy, Go ships with a JRE in exactly that version. I don't think Go would try to build with it's own JRE, but will always use what I configured for Maven.

Am I missing something or am I facing a bug in Go or the RequireJavaVersion plugin?

If anybody had similar issues, I'd be glad to hear about it.

Regards

Soren

Jyoti Singh

unread,
Dec 18, 2014, 4:09:44 AM12/18/14
to go...@googlegroups.com
Hi Soren,

Go installer for windows does include OpenJDK jre7, and used as default java by both Go agent and server.
This is set using a system level environment variable GO_AGENT_JAVA_HOME. You can change this to any other version of java that suits you. Please not java8 has not been tested yet with Go, so I wouldn't recommend changing the above variable to that. 
The other option you have is to set JAVA_HOME environment variable at a 'pipeline' or 'environment' level in Go's config. This will make sure your jobs under that pipeline get the right version of java.

Hope that helps.

Cheers,
Jyoti

Soren Cito

unread,
Dec 18, 2014, 9:33:22 AM12/18/14
to go...@googlegroups.com
Hi Jyoti,

thanks for your reply. I have already found out that I am not running JRE 1.7 (despite the error message, which probably is special effect provided by the RequireJavaVersion enforcer plugin) by just adding another Go job calling "java -version" to my pipeline which outputs 1.8. But it's a JRE, not a JDK. And indeed, it's the JRE that is installed and referred to by my Windows installation. So what is actually wrong is that Windows somehow hides my JDK from Go when running as a service with the system user (this is what I think at least). So I'll remove the JRE from my system and just leave the JDK in place. I feel this is just a hack. Anyway, the real problem seems to be trying to run a CI server on Windows ;-)

Thanks again and cheers

Soren

Md. Ali Ejaz

unread,
Dec 19, 2014, 1:04:30 AM12/19/14
to Soren Cito, go...@googlegroups.com
Hey Soren,

It doesn't sound right. As long as you set the GO_AGENT_JAVA_HOME and/or GO_SERVER_JAVA_HOME system environment variables Go should pick us the desired java (JDK or JRE whichever you had set)!

If you somehow figure out the issue, do let me know. Just curious :)

--
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 go-cd+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Ali
@mdaliejaz

Soren Cito

unread,
Dec 19, 2014, 3:29:30 AM12/19/14
to go...@googlegroups.com
Hi Ali, hi Jyoti,

I just did what you guys supposed and now the compile jobs runs green! :-) Thanks.

Anyway, this makes me worry. No matter what my JAVA_HOME says or what I configured in the build (using the Maven compiler plugin), Go will ignore it and use whatever is configured in it's own environment variables. Does that mean that I have to set up two agents on two machines when I have another build requiring another JDK? I could probably distinguish them using "Resources", right?

From my perspective this looks like a bug. What is your opinion on this?

Thanks and best regards

Soren

Md. Ali Ejaz

unread,
Dec 22, 2014, 12:58:03 AM12/22/14
to Soren Cito, go...@googlegroups.com
Hey Soren,

I just did what you guys supposed and now the compile jobs runs green! :-) Thanks.
Glad it worked for you.

 Anyway, this makes me worry. No matter what my JAVA_HOME says or what I configured in the build (using the Maven compiler plugin), Go will ignore it and use whatever is configured in it's own environment variables. Does that mean that I have to set up two agents on two machines when I have another build requiring another JDK? I could probably distinguish them using "Resources", right?
From my perspective this looks like a bug. What is your opinion on this?

Go agent requires java (GO_AGENT_JAVA_HOME) for itself and wouldn't work without it.
Now coming to your question/concern, this GO_AGENT_JAVA_HOME is required by Go to run itself and any task inside Go picks up this java by default. If you want a particular pipeline or job to run with another JAVA_HOME then you could set the JAVA_HOME variable at the pipeline/stage/job level environment variable. This will ensure that your job picks up the right java version.
Hope this answers your concern :)
 

--
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 go-cd+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
- Ali
@mdaliejaz
Reply all
Reply to author
Forward
0 new messages