1
votes

I'm trying to have Hudson compile a Java project of mine, but it keeps failing.

I've started a new job, with "build a free-style software project"

I've set the SCM to Mercurial, added a build step "mvn compile" and had it publish Junit and JDepend results. JUnit test report simple named "*.xml"

The cloning of the repo works, but the repo refuses to compile. I get this error message:

[workspace] $ /usr/local/bin/hg log --rev . --template {node}
[workspace] $ /bin/bash -xe /tmp/hudson1162267116265588070.sh
+ mvn compile
/tmp/hudson1162267116265588070.sh: line 2: mvn: command not found
Recording test results
[JDepend] JDepend plugin is ready
[JDepend] Starting JDepend file, outputting to /tmp/jdepend6348540211061861772.xml
[JDepend] Found 2 classes in 1 packages
Finished: FAILURE

EDIT: result of mvn -ver

Java version: 1.6.0_21
Java home: /usr/java/jdk1.6.0_21/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-25-generic" arch: "i386" Family: "unix"

Also, what I added to my /etc/bash.bashrc file.

export JAVA_HOME=/usr/java/jdk1.6.0_21
export M2_HOME=/usr/local/apache-maven/apache-maven-2.2.1
export M2=$M2_HOME/bin
export MAVEN_OPTS="-Xms256m -Xmx512m"
export PATH=$M2:$PATH

export MAVEN_HOME=/usr/local/apache-maven/apache-maven-2.2.1
export MAVEN=$MAVEN_HOME/bin

And the $PATH echo.

/usr/local/apache-maven/apache-maven-2.2.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/java/jdk1.6.0_21/bin

1
Can you run "mvn -ver", if that command fails it's a problem with Maven, not Hudson.Andy

1 Answers

1
votes

The essential part of John V's answer and its comments.

It can't find maven, because it is not in the path. If you set the path in Hudson's .profile you are out of luck. The profile will only be executed for login shells. AFAIK, Hudson opens a non-interactive shell to execute the build steps and therefore, the .profile will not be executed.

When you login using the Hudson user account and run the maven command you will not have any problems, since the profile is correctly executed.