Re: Switch JDK between build steps

2012-03-27 Thread domi
you could use this plugin: 
https://wiki.jenkins-ci.org/display/JENKINS/Tool+Environment+Plugin
to reuse the JDK definitions (JAVA_HOME) for your scripts - this way you at 
least don't have to hard code JAVA_HOME…
/imod

On 27.03.2012, at 16:25, Andreas wrote:

> Hi,
> 
> my current favorite solution is to define a special ant and maven version as 
> Jenkins tools. Lets say ant-sonar and maven-sonar. Once installed I add to 
> the ant / mvn script of these tool installations:
> 
> ## Special code to get a fix 1.6 jdk to run sonar 2.14
> JAVA_HOME=/usr/share/jdk1.6.0_20
> export JAVA_HOME
> echo \*\*\* Using hardcoded JAVA_HOME in \"`basename $0`\" pointing to 
> \"$JAVA_HOME\". >&2
> 
> It is still kind of a hack but it limits the effort that has to go in the 
> reconfiguration of each job.
> 
> 
> Kind Regards, Andreas.
> 
> Am Montag, 26. März 2012 11:54:15 UTC+2 schrieb Andreas:
> Hi,
> 
> 
> I face the issue that I have to use different JDKs for different build steps. 
> Namely I need to invoke the compile step in ant with a 1.5 JDK and run the 
> sonar ant target with a 1.6 JDK. There is no easy way to split this job, so a 
> multi job setup is no solution here. Also I do not want to fork into a 
> different JDK in ant manually - actually only Jenkins knows where the JDK is 
> installed on the build node. 
> 
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
> 
> Is there an easy, already existing solution? Any ideas are welcome.
> 
> 
> Kind Regards, Andreas.
> 
> Am Montag, 26. März 2012 11:54:15 UTC+2 schrieb Andreas:
> Hi,
> 
> 
> I face the issue that I have to use different JDKs for different build steps. 
> Namely I need to invoke the compile step in ant with a 1.5 JDK and run the 
> sonar ant target with a 1.6 JDK. There is no easy way to split this job, so a 
> multi job setup is no solution here. Also I do not want to fork into a 
> different JDK in ant manually - actually only Jenkins knows where the JDK is 
> installed on the build node. 
> 
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
> 
> Is there an easy, already existing solution? Any ideas are welcome.
> 
> 
> Kind Regards, Andreas.
> 
> Am Montag, 26. März 2012 11:54:15 UTC+2 schrieb Andreas:
> Hi,
> 
> 
> I face the issue that I have to use different JDKs for different build steps. 
> Namely I need to invoke the compile step in ant with a 1.5 JDK and run the 
> sonar ant target with a 1.6 JDK. There is no easy way to split this job, so a 
> multi job setup is no solution here. Also I do not want to fork into a 
> different JDK in ant manually - actually only Jenkins knows where the JDK is 
> installed on the build node. 
> 
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
> 
> Is there an easy, already existing solution? Any ideas are welcome.
> 
> 
> Kind Regards, Andreas.
> 
> Am Montag, 26. März 2012 11:54:15 UTC+2 schrieb Andreas:
> Hi,
> 
> 
> I face the issue that I have to use different JDKs for different build steps. 
> Namely I need to invoke the compile step in ant with a 1.5 JDK and run the 
> sonar ant target with a 1.6 JDK. There is no easy way to split this job, so a 
> multi job setup is no solution here. Also I do not want to fork into a 
> different JDK in ant manually - actually only Jenkins knows where the JDK is 
> installed on the build node. 
> 
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
> 
> Is there an easy, already existing solution? Any ideas are welcome.
> 
> 
> Kind Regards, Andreas.
> 
> Am Montag, 26. März 2012 11:54:15 UTC+2 schrieb Andreas:
> Hi,
> 
> 
> I face the issue that I have to use different JDKs for different build steps. 
> Namely I need to invoke the compile step in ant with a 1.5 JDK and run the 
> sonar ant target with a 1.6 JDK. There is no easy way to split this job, so a 
> multi job setup is no solution here. Also I do not want to fork into a 
> different JDK in ant manually - actually only Jenkins knows where the JDK is 
> installed on the build node. 
> 
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
> 
> Is there an easy, already existing solution? Any ideas are welcome.
> 
> 
> Kind Regards, Andreas.



Re: Switch JDK between build steps

2012-03-27 Thread Andreas
Hi,

my current favorite solution is to define a special ant and maven version 
as Jenkins tools. Lets say ant-sonar and maven-sonar. Once installed I add 
to the ant / mvn script of these tool installations:

## Special code to get a fix 1.6 jdk to run sonar 2.14
JAVA_HOME=/usr/share/jdk1.6.0_20
export JAVA_HOME
echo \*\*\* Using hardcoded JAVA_HOME in \"`basename $0`\" pointing to 
\"$JAVA_HOME\". >&2

It is still kind of a hack but it limits the effort that has to go in the 
reconfiguration of each job.


Kind Regards, Andreas.

Am Montag, 26. März 2012 11:54:15 UTC+2 schrieb Andreas:
>
> Hi,
>
>
> I face the issue that I have to use different JDKs for different build 
> steps. Namely I need to invoke the compile step in ant with a 1.5 JDK and 
> run the sonar ant target with a 1.6 JDK. There is no easy way to split this 
> job, so a multi job setup is no solution here. Also I do not want to fork 
> into a different JDK in ant manually - actually only Jenkins knows where 
> the JDK is installed on the build node. 
>
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
>
> Is there an easy, already existing solution? Any ideas are welcome.
>
>
> Kind Regards, Andreas.
>

Am Montag, 26. März 2012 11:54:15 UTC+2 schrieb Andreas:
>
> Hi,
>
>
> I face the issue that I have to use different JDKs for different build 
> steps. Namely I need to invoke the compile step in ant with a 1.5 JDK and 
> run the sonar ant target with a 1.6 JDK. There is no easy way to split this 
> job, so a multi job setup is no solution here. Also I do not want to fork 
> into a different JDK in ant manually - actually only Jenkins knows where 
> the JDK is installed on the build node. 
>
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
>
> Is there an easy, already existing solution? Any ideas are welcome.
>
>
> Kind Regards, Andreas.
>

Am Montag, 26. März 2012 11:54:15 UTC+2 schrieb Andreas:
>
> Hi,
>
>
> I face the issue that I have to use different JDKs for different build 
> steps. Namely I need to invoke the compile step in ant with a 1.5 JDK and 
> run the sonar ant target with a 1.6 JDK. There is no easy way to split this 
> job, so a multi job setup is no solution here. Also I do not want to fork 
> into a different JDK in ant manually - actually only Jenkins knows where 
> the JDK is installed on the build node. 
>
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
>
> Is there an easy, already existing solution? Any ideas are welcome.
>
>
> Kind Regards, Andreas.
>

Am Montag, 26. März 2012 11:54:15 UTC+2 schrieb Andreas:
>
> Hi,
>
>
> I face the issue that I have to use different JDKs for different build 
> steps. Namely I need to invoke the compile step in ant with a 1.5 JDK and 
> run the sonar ant target with a 1.6 JDK. There is no easy way to split this 
> job, so a multi job setup is no solution here. Also I do not want to fork 
> into a different JDK in ant manually - actually only Jenkins knows where 
> the JDK is installed on the build node. 
>
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
>
> Is there an easy, already existing solution? Any ideas are welcome.
>
>
> Kind Regards, Andreas.
>

Am Montag, 26. März 2012 11:54:15 UTC+2 schrieb Andreas:
>
> Hi,
>
>
> I face the issue that I have to use different JDKs for different build 
> steps. Namely I need to invoke the compile step in ant with a 1.5 JDK and 
> run the sonar ant target with a 1.6 JDK. There is no easy way to split this 
> job, so a multi job setup is no solution here. Also I do not want to fork 
> into a different JDK in ant manually - actually only Jenkins knows where 
> the JDK is installed on the build node. 
>
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
>
> Is there an easy, already existing solution? Any ideas are welcome.
>
>
> Kind Regards, Andreas.
>


Re: Switch JDK between build steps

2012-03-27 Thread Andreas
Hi,

this sounds like a plan. I still need to convert the build steps into shell 
script steps but it should be possible to find all tools based on the 
environment variables. I would loose the install magic, since there is no 
way for Jenkins to know which JDK the job uses but at least I've a chance 
to switch the JDK. Mid-term I think it would be cleaner to have the joce 
with the ANT/Maven build step. Might be other tools come up with the 
requirement to use a certain special JDK that is different than the one 
needed for the target platform - like Sonar 2.14.

Kind Regards, Andreas.



Am Montag, 26. März 2012 16:18:56 UTC+2 schrieb domi:
>
> Maybe this plugin helps, it lets you expose the different JDK HOMEs as 
> environment variables:
> https://wiki.jenkins-ci.org/display/JENKINS/Tool+Environment+Plugin
> /imod
>
> On 26.03.2012, at 15:55, Andreas wrote:
>
> Hi, 
>
> thanks for the feedback and the idea. Unfortunately I think, this will not 
> work in my setup. I've several builds running in parallel, also I want to 
> have the JDKs auto installed by Jenkins.
>
> Kind Regards, Andreas.
>
> Am Montag, 26. März 2012 13:15:33 UTC+2 schrieb Didier Durand:
>>
>> Hi,
>>
>> To my knowledge Jenkins launches a separate jvm for each step you 
>> configure in the "Build" section of your job configuration
>>
>> So, I would try to alternate your build steps under Ant with shell build 
>> steps and use these shell steps to switch the jvm/jre as you want  (via for 
>> example. the linux "alternatives" command)
>>
>>
>> regards 
>>
>> didier
>>
>>
>> Le lundi 26 mars 2012 11:54:15 UTC+2, Andreas a écrit :
>>>
>>> Hi,
>>>
>>>
>>> I face the issue that I have to use different JDKs for different build 
>>> steps. Namely I need to invoke the compile step in ant with a 1.5 JDK and 
>>> run the sonar ant target with a 1.6 JDK. There is no easy way to split this 
>>> job, so a multi job setup is no solution here. Also I do not want to fork 
>>> into a different JDK in ant manually - actually only Jenkins knows where 
>>> the JDK is installed on the build node. 
>>>
>>> I face a similar requirement for maven goals. 
>>>  
>>> I'm thinking about extending the ANT plugin to allow JDK selection in 
>>> the advanced options and the set JAVA_HOME accordingly. 
>>>
>>> Is there an easy, already existing solution? Any ideas are welcome.
>>>
>>>
>>> Kind Regards, Andreas.
>>>
>>
>

Re: Switch JDK between build steps

2012-03-26 Thread domi
Maybe this plugin helps, it lets you expose the different JDK HOMEs as 
environment variables:
https://wiki.jenkins-ci.org/display/JENKINS/Tool+Environment+Plugin
/imod

On 26.03.2012, at 15:55, Andreas wrote:

> Hi, 
> 
> thanks for the feedback and the idea. Unfortunately I think, this will not 
> work in my setup. I've several builds running in parallel, also I want to 
> have the JDKs auto installed by Jenkins.
> 
> Kind Regards, Andreas.
> 
> Am Montag, 26. März 2012 13:15:33 UTC+2 schrieb Didier Durand:
> Hi,
> 
> To my knowledge Jenkins launches a separate jvm for each step you configure 
> in the "Build" section of your job configuration
> 
> So, I would try to alternate your build steps under Ant with shell build 
> steps and use these shell steps to switch the jvm/jre as you want  (via for 
> example. the linux "alternatives" command)
> 
> 
> regards 
> 
> didier
> 
> 
> Le lundi 26 mars 2012 11:54:15 UTC+2, Andreas a écrit :
> Hi,
> 
> 
> I face the issue that I have to use different JDKs for different build steps. 
> Namely I need to invoke the compile step in ant with a 1.5 JDK and run the 
> sonar ant target with a 1.6 JDK. There is no easy way to split this job, so a 
> multi job setup is no solution here. Also I do not want to fork into a 
> different JDK in ant manually - actually only Jenkins knows where the JDK is 
> installed on the build node. 
> 
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
> 
> Is there an easy, already existing solution? Any ideas are welcome.
> 
> 
> Kind Regards, Andreas.



Re: Switch JDK between build steps

2012-03-26 Thread Andreas
Hi, 

thanks for the feedback and the idea. Unfortunately I think, this will not 
work in my setup. I've several builds running in parallel, also I want to 
have the JDKs auto installed by Jenkins.

Kind Regards, Andreas.

Am Montag, 26. März 2012 13:15:33 UTC+2 schrieb Didier Durand:
>
> Hi,
>
> To my knowledge Jenkins launches a separate jvm for each step you 
> configure in the "Build" section of your job configuration
>
> So, I would try to alternate your build steps under Ant with shell build 
> steps and use these shell steps to switch the jvm/jre as you want  (via for 
> example. the linux "alternatives" command)
>
>
> regards 
>
> didier
>
>
> Le lundi 26 mars 2012 11:54:15 UTC+2, Andreas a écrit :
>>
>> Hi,
>>
>>
>> I face the issue that I have to use different JDKs for different build 
>> steps. Namely I need to invoke the compile step in ant with a 1.5 JDK and 
>> run the sonar ant target with a 1.6 JDK. There is no easy way to split this 
>> job, so a multi job setup is no solution here. Also I do not want to fork 
>> into a different JDK in ant manually - actually only Jenkins knows where 
>> the JDK is installed on the build node. 
>>
>> I face a similar requirement for maven goals. 
>>  
>> I'm thinking about extending the ANT plugin to allow JDK selection in the 
>> advanced options and the set JAVA_HOME accordingly. 
>>
>> Is there an easy, already existing solution? Any ideas are welcome.
>>
>>
>> Kind Regards, Andreas.
>>
>

Re: Switch JDK between build steps

2012-03-26 Thread Didier Durand
Hi,

To my knowledge Jenkins launches a separate jvm for each step you configure 
in the "Build" section of your job configuration

So, I would try to alternate your build steps under Ant with shell build 
steps and use these shell steps to switch the jvm/jre as you want  (via for 
example. the linux "alternatives" command)


regards 

didier


Le lundi 26 mars 2012 11:54:15 UTC+2, Andreas a écrit :
>
> Hi,
>
>
> I face the issue that I have to use different JDKs for different build 
> steps. Namely I need to invoke the compile step in ant with a 1.5 JDK and 
> run the sonar ant target with a 1.6 JDK. There is no easy way to split this 
> job, so a multi job setup is no solution here. Also I do not want to fork 
> into a different JDK in ant manually - actually only Jenkins knows where 
> the JDK is installed on the build node. 
>
> I face a similar requirement for maven goals. 
>  
> I'm thinking about extending the ANT plugin to allow JDK selection in the 
> advanced options and the set JAVA_HOME accordingly. 
>
> Is there an easy, already existing solution? Any ideas are welcome.
>
>
> Kind Regards, Andreas.
>


Switch JDK between build steps

2012-03-26 Thread Andreas
Hi,


I face the issue that I have to use different JDKs for different build 
steps. Namely I need to invoke the compile step in ant with a 1.5 JDK and 
run the sonar ant target with a 1.6 JDK. There is no easy way to split this 
job, so a multi job setup is no solution here. Also I do not want to fork 
into a different JDK in ant manually - actually only Jenkins knows where 
the JDK is installed on the build node. 

I face a similar requirement for maven goals. 
 
I'm thinking about extending the ANT plugin to allow JDK selection in the 
advanced options and the set JAVA_HOME accordingly. 

Is there an easy, already existing solution? Any ideas are welcome.


Kind Regards, Andreas.