Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-15767

Maven task assumes incorrect M2_HOME and MAVEN2_HOME, and build fails

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Low Low
    • None
    • 5.7.2
    • Maven
    • None

      To configure a Maven 3 capability you must NOT set the path to the executable to the actual location of mvn, as Bamboo will append /bin/mvn by itself.
      E.g. Maven is at /usr/bin/mvn, then you have to configure the executable path to just /usr.
      See also https://jira.atlassian.com/browse/BAM-12364

      The workaround seems simple, just configure the Maven capability with the shortened path.
      However, when you start a Maven task, it does this:

      simple  25-Mar-2015 08:19:54  Starting task 'Maven3 test' of type 'com.atlassian.bamboo.plugins.maven:task.builder.mvn3'
      command 25-Mar-2015 08:19:54  Beginning to execute external process for build 'My Project - My Plan - Default Job #4 (MYPROJ-MYPLAN-JOB1-4)'\n ... running command line: \n/usr/bin/mvn --batch-mode -Djava.io.tmpdir=/home/rene/bamboo/app/temp/MYPROJ-MYPLAN-JOB1 clean test\n ... in: /home/rene/bamboo/home/xml-data/build-dir/MYPROJ-MYPLAN-JOB1/my-app\n ... using extra environment variables: \nbamboo_build_commandline_com_atlassian_bamboo_plugins_scripttask_task_builder_script_1=/bin/sh /home/rene/bamboo/app/temp/MYPROJ-MYPLAN-JOB1-4-ScriptBuildTask-8184373204504937809.sh\nbamboo_buildPlanName=My Project - My Plan - Default Job\nbamboo_capability_system_jdk_JDK_1_7=/usr/lib/jvm/default-java\nJAVA_HOME=/usr/lib/jvm/default-java\nuseMavenReturnCode=false\nbamboo_shortPlanName=My Plan\nbamboo_resultsUrl=http://127.0.1.1:8085/browse/MYPROJ-MYPLAN-JOB1-4\nbamboo_planKey=MYPROJ-MYPLAN\nbamboo_ManualBuildTriggerReason_userName=rene\nMAVEN2_HOME=/usr\nbamboo_capability_system_jdk_JDK_1_7_0_75=/usr/lib/jvm/default-java\nbamboo_shortPlanKey=MYPLAN\nbamboo_shortJobKey=JOB1\nbamboo_build_working_directory=/home/rene/bamboo/home/xml-data/build-dir/MYPROJ-MYPLAN-JOB1\nbamboo_capability_system_jdk_JDK=/usr/lib/jvm/default-java\nbamboo_shortJobName=Default Job\nbamboo_agentId=131073\nM2_HOME=/usr\nbamboo_planName=My Project - My Plan\nbamboo_buildResultsUrl=http://127.0.1.1:8085/browse/MYPROJ-MYPLAN-JOB1-4\nbamboo_buildResultKey=MYPROJ-MYPLAN-JOB1-4\nbamboo_buildKey=MYPROJ-MYPLAN-JOB1\nbamboo_dependenciesDisabled=false\nbamboo_working_directory=/home/rene/bamboo/home/xml-data/build-dir/MYPROJ-MYPLAN-JOB1\nbamboo_buildNumber=4\nbamboo_capability_system_builder_mvn3_maven3=/usr\nbamboo_capability_system_builder_ant_Ant=/usr/share/ant\nbamboo_agentWorkingDirectory=/home/rene/bamboo/home/xml-data/build-dir\nbamboo_buildTimeStamp=2015-03-25T08:19:53.961-07:00\nPATH=/usr/lib/jvm/default-java/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\n
      error 25-Mar-2015 08:19:54  Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
      simple  25-Mar-2015 08:19:54  Failing task since return code of [/usr/bin/mvn --batch-mode -Djava.io.tmpdir=/home/rene/bamboo/app/temp/MYPROJ-MYPLAN-JOB1 clean test] was 1 while expected 0
      
      

      There was no M2_HOME or MAVEN2_HOME environment variable defined.
      Bamboo creates them when starting the Maven build, but sets them to the shortened path.
      So /usr instead of /usr/bin/mvn.

      As a result the build fails with "Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher" which is typical for an incorrect M2_HOME/MAVEN2_HOME (or even M3_HOME/MAVEN3_HOME, but that's another discussion).

      Also tried setting the M2_HOME, MAVEN2_HOME, M3_HOME, and MAVEN3_HOME environment variables, but Bamboo just overrules M2_HOME and MAVEN2_HOME with the shortened path.

      Instead of using /usr I also tried /usr/share/maven as paths, all to no avail.

      A workaround is to call Maven from a normal Script Task, but then you lose the Test integration.

              Unassigned Unassigned
              rverschoor Rene Verschoor (Inactive)
              Votes:
              8 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated: