Jenkins ignores Maven profile properties

50 views
Skip to first unread message

Martijn Hiemstra

unread,
Feb 9, 2016, 8:50:30 AM2/9/16
to Jenkins Users
I have a maven project and locally everything perfectly. When I do maven tomcat7:redeploy everything works perfectly. When I run that same project on Jenkins then the wrong profile properties are loaded. 

This is the situation. In my pom.xml in the build plugins section I have this:

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<server>${tomcat-server}</server>
<url>${tomcat-url}</url>
<path>${tomcat-context}</path>
</configuration>
</plugin>

In my settings.xml I have this:

  <profiles>
    <profile>
      <id>tomcat-localhost</id>
      <properties>
        <tomcat-server>local.server</tomcat-server>
        <tomcat-url>http://localhost:8080/manager/text</tomcat-url>
        <tomcat-context>/MyProject</tomcat-context>
      </properties>
    </profile>
    <profile>
      <id>tomcat-test</id>
      <properties>
        <tomcat-server>test.server</tomcat-server>
        <tomcat-url>http://10.101.55.43:8080/manager/text</tomcat-url>
        <tomcat-context>/</tomcat-context>
      </properties>
    </profile>
  </profiles>

in the servers section I have defined the username and passwords for the servers. Now I configure my Maven project in Jenkins and in the maven section I set this in the goals and options field:

tomcat7:redeploy -P tomcat-test

This means that Jenkins should load the properties of the profile with id tomcat-test however when the war file gets uploaded I see this in the job console:

Uploading: http://localhost:8080/manager/text/deploy?path=%2FMyProject&update=true

Even though I have clearly indicated that maven should load the tomcat-test properties, it loads the tomcat-localhost instead. Outside of Jenkins, locally on my machine, it works properly.



Arnaud Héritier

unread,
Feb 16, 2016, 3:27:35 AM2/16/16
to jenkins...@googlegroups.com
Hi Martijn,


  How did you ensure that the maven settings.xml file is used by your build ? Did you manually deployed it on the slave where the job is executed or by using a plugin like the Config File Provider ?
  What you did seems good, thus I think that the problem is that Maven doesn't see at all your settings.xml file

cheers

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3182dd36-d761-42de-ab65-544e742fa131%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-----
Arnaud Héritier
Mail/GTalk: aheritier AT gmail DOT com
Twitter/Skype : aheritier
Reply all
Reply to author
Forward
0 new messages