Additional Maven Command Line Parameters not working on a linux build agent

For our builds, we have a master maven plugin that does all our work.  We can turn on certain optional features by using -D parameters (ex. -DexecuteSonar).  For our builds working on windows build agents, this works great.  I can see the -D parameter being used in the build log, and the debug output statements in our plugin shows the value for the flag being true.

However on the linux agent, I do not see the -D parameter in the build log anywhere, and the plugin's debug output statement is informing us that it was not set.

Is there something I need to setup on the linux agent to get it to use the Additional Maven Command Line Parameters correctly?

-Scott

13 comments
Comment actions Permalink

Could you please provide your additional command line parameters string and the build log.

You can try to workaround this by setting a system property in the build configuration settings.

0
Comment actions Permalink

Sorry didn't reply sooner, i never got an email saying someone responded

additional maven parameters: -U -cpu -DexecuteSonar

build log attached.

Thanks!
-Scott



Attachment(s):
build.log.zip
0
Comment actions Permalink

My tests are showing system properties are passed correctly both on windows and linux.
To check this on your side please add the following snippet to your pom.xml

  <build>
...
    <plugins>
     <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
       <version>1.3</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <configuration>
              <tasks>
                <echo message="executeSonar = ${executeSonar}"/>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
...
  </build>

and launch a build on your linux agent. It will print the value of your system property (which should be 'true').

Also, in your build log I've found the following text:
...
[13:23:29]: [INFO] ------------------------------------------------------------------------
[13:23:29]: [INFO] Building Monsanto Repliweb
[13:23:29]: [INFO]    task-segment: [com.monsanto.tps:masterbuild-maven-plugin:1.0.9-SNAPSHOT:selective-sonar] (aggregator-style)
[13:23:29]: [INFO] ------------------------------------------------------------------------
[13:23:31]: [INFO] [masterbuild:selective-sonar]
[13:23:31]: executeSonar = true
[13:23:31]: [INFO] Executing Maven command: mvn sonar:sonar
[13:23:32]: [INFO] Scanning for projects...
...
Doesn't this mean that your build has successfully detected the presence of your parameter?

0
Comment actions Permalink

No, we modified our plugin to default it to true, i'll put in that plugin to my maven build and let you know how it goes.

-scott

0
Comment actions Permalink


I did change the configuration to set the  -DexecuteSonar=false and the log entry for executeSonar still said true  (the default)

The echo came out "[echo] ECHO executeSonar = ${executeSonar}. "

If I login to the linux box and do a mvn compile -DexecuteSonar = false I see "[echo] ECHO executeSonar=false"

So it seems pretty clear that maven parameter is not making it down to the linux agents, due to some configuration or something.

0
Comment actions Permalink

here is what is in the profile of the linux build agent, would any of these interfere?

umask 022
PATH=/ci/tools/subversion-1.6.6/bin:$PATH:/ci/tools/apache-maven-2.0.8/bin:/ci/www
M2_HOME=/ci/tools/apache-maven-2.0.8 export M2_HOME
JAVA_HOME=/ci/java/java export JAVA_HOME
WL_HOME=/ci export WL_HOME
MONCRYPTJV=/ci/moncryptjv export MONCRYPTJV
CATALINA_HOME=/ci/www/tomcat_5.5.20 export CATALINA_HOME
CATALINA_BASE=$CATALINA_HOME export CATALINA_BASE
MAVEN_OPTS="-Xmx960m -XX:MaxPermSize=256m -Duser.timezone=America/Chicago" export MAVEN_OPTS

PLATFORM_TEAM=TPS export PLATFORM_TEAM
DP_PASSWORD_FILE_LOC=/ci/tools/na1000app-tpsdp.password export DP_PASSWORD_FILE_LOC
TEAMCITY_AGENT_OPTS="-Dserver.logs=/ci/projects/logs" export TEAMCITY_AGENT_OPTS
DISPLAY=:0 export DISPLAY
LANG=en_US.iso-8859-15 export LANG

0
Comment actions Permalink

Scott,

Could you please create a sample build configuration just with the pom I listed in the previous message, run a build on a linux agent and send me the build log.

Thank you.

Also, did you try the workaround with setting a system property instead of passing it via command line?

0
Comment actions Permalink

No. I don't see any problem with the profile

0
Comment actions Permalink

Also to make the experiment clean enough please change the name of the property to something neutral and unique, say "_prop_1" or alike.
Thank you.

0
Comment actions Permalink

System property isn't a valid workaround since we won't be able to turn off/on, and doesn't help us with the -U -cpu not getting across.

I did try out the empty project, and it was enlightening, when i did mvn compile it worked perfectly, and i saw the value i passed into to the optional parameters.  So good there.

When I changed the goal to be our 'masterbuild' maven plugin, then it reverted back to not seeing the -D_prop_1=hi i passed in.  However, it sees it fine on the windows box.  So it looks like there's an issue passing along the parameters to a 2nd level plugin somehow.  It might be related to how maven runs on windows vs how it runs on linux.  I'll look at our plugin and see if there something we can do there, but let me know if you have any ideas.

I've attached the windows agent log & linux agent log for the same sample project.



Attachment(s):
windowsagent.log.zip
linuxagent.log.zip
0
Comment actions Permalink

I mean setting a system property not for the agent JVM, but in the build configuratio settings. See step 6 "Properties and environment variables".
Setting a property in there is essentially the same thing as setting it in the command line on the runner settings page.

Since I don't know how your plugin determines the command line parameters on the first level of maven execution, I can't figure out what goes wrong then on the second level on linux agents. Could please explain your build mechanism in a bit more detail?

0
Comment actions Permalink

OK, we think found the issue.  The mvn.bat file apache distrubutes as part of the windows install includes the command line parameters as a variable, the but linux shell script does not do that (at least for 2.0.8 maven), once we fixed the linux shell script to do what the windows batch file did, everything started working.

The lines we added to the mvn shell script were
MAVEN_CMD_LINE_ARGS="$@"
export MAVEN_CMD_LINE_ARGS

0
Comment actions Permalink

OK. I see. Thank you for the clarification.

0

Please sign in to leave a comment.