Spring application Jenkins deployment - environments Spring application Jenkins deployment - environments jenkins jenkins

Spring application Jenkins deployment - environments


I think you have several options:
If you insist to use the same build war for all environments you can add a Global MAVEN_OPTS : in Jenkins go to main menu Manage Jenkins->Configure System and try to set the Global MAVEN_OPTS with : -Dspring.profiles.active=int

Another option should be to use the Maven Profile to build a specific war with the appropriate properties file in Jenkins. And so in your Jenkins job configuration add the goals and options maven command in the build step (for i.e. clean install –Pint where "int" is your Maven profile id for Jenkins


Best way would be to follow 12 FActor App principles, where all properties are passed into your app via environment variables. That would conform to "cloud native" application.

But if you don't want to do that, you can use it the way you are describing. Property spring.profiles.active will be configured on runtime, not in Jenkins build. All config files can be included in WAR file. It's very inflexible, because as some environment properties change, you will need to kick off new build -> new version.

Biggest problem with this approach is that it doesn't scale. In cloud environment, you may want to have a lot of different PROD environments with different configurations. If your WAR artifact locked configuration withing single config file, you have only one PROD configuration.

Some deployment systems work the way that configuration files have placeholders and you replace these placeholders during deployment. So you can have one PROD configuration file, but deployment pipeline will replace placeholders with values for different PROD nodes.