Quantcast

Newbie Question: Groovy import doesn't work under Jenkins

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Newbie Question: Groovy import doesn't work under Jenkins

Frank Merrow

I have this meaningless test class:

 

public class Test {

  public String MyString() { return "This is my String"; }

}

 

And this driving script:

 

Import Test

 

test = new Test();

Println(test.MyString());

 

So I’ve already gotten by the problem in groovyConsole that the import didn’t work from any directory except “.”, by putting the path the class is in directly in CLASSPATH.  I put that in by adjusting my system CLASSPATH variable and I’ve ensure it survives reboot.

 

This script works from any directory now using groovyConsole.

 

However, when I try the same script in Jenkins (either Scriptler or Script Console) the import fails.

 

It fails even if I add “-cp <dirpath>” or “—cp <dirpath>” (wasn’t sure which was correct) to the Jenkins command line.

 

I have rebooted since adjusting CLASSPATH, verified CLASSPATH still works under groovyConsole and restarted my system and Jenkins any number of times thinking Jenkins  might have a cached version of my environment variables . . . still no joy.

 

In short, CLASSPATH doesn’t seem to be working for Jenkins Groovy at all.

 

What am I missing?

 

Frank

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Newbie Question: Groovy import doesn't work under Jenkins

Les Mikesell
On Sun, Mar 11, 2012 at 12:18 PM, Frank Merrow <[hidden email]> wrote:

>
> I have rebooted since adjusting CLASSPATH, verified CLASSPATH still works
> under groovyConsole and restarted my system and Jenkins any number of times
> thinking Jenkins  might have a cached version of my environment variables .
> . . still no joy.
>
>
>
> In short, CLASSPATH doesn’t seem to be working for Jenkins Groovy at all.
>
>
>
> What am I missing?

Where are you setting CLASSPATH?  Jenkins jobs don't run in the same
context as a console user.   And do you get what you expect in the job
console ouput if you run a groovy job that just says
println System.getenv("CLASSPATH")

--
   Les Mikesell
     [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Newbie Question: Groovy import doesn't work under Jenkins

Frank Merrow-2

I set CLASSPATH in the system side of the Advance System Settings Environment . . .

 

Thanks for the code example and yes, CLASSPATH looks as expected:

 

.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip;C:\Users\Merrow\test

 

It all works from Groovy Console . . . I just have no idea why it doesn't work from Jenkins . . .

 

I am running it as a Windows Service, but from the results above, clearly CLASSPATH is set correctly.

 

You're saying is "should work" . . . interesting . . . I’m not sure what to do with that . . . but interesting.

 

Frank

 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Les Mikesell
Sent: Sunday, March 11, 2012 8:46 PM
To: [hidden email]
Subject: Re: Newbie Question: Groovy import doesn't work under Jenkins

 

On Sun, Mar 11, 2012 at 12:18 PM, Frank Merrow <[hidden email]> wrote:

> 

> I have rebooted since adjusting CLASSPATH, verified CLASSPATH still

> works under groovyConsole and restarted my system and Jenkins any

> number of times thinking Jenkins  might have a cached version of my environment variables .

> . . still no joy.

> 

> 

> 

> In short, CLASSPATH doesn’t seem to be working for Jenkins Groovy at all.

> 

> 

> 

> What am I missing?

 

Where are you setting CLASSPATH?  Jenkins jobs don't run in the same

context as a console user.   And do you get what you expect in the job

console ouput if you run a groovy job that just says println System.getenv("CLASSPATH")

 

--

   Les Mikesell

     [hidden email]

Loading...