Jenkins construction for different conditions

I currently have a Jenkins instance installed in the development window. This works great and is deployed in our development environment without any problem.

During the build process, my project uses a single properties file containing data such as the URL of the database connection (such data will obviously change depending on the environment I point to).

What I would like to know is the best way to set up my project so that when I want to release to Production, the WAR file generated by Jenkins contains Production properties instead of Development?

(Note: I am also using Maven in my project).

+3


source to share


2 answers


You can create different maven profiles like dev

, prod

then in profile settings use / filter the corresponding resource files like .../(dev|test|prod)/project.properties

. And in Jenkins, when you build for a different platform, build with -Pdev or -Pprod

to get the war on the right target.

You can check maven profile, maven resource filtering for detailed configuration.



something unrelated, connect the database via jndi if possible.

+1


source


I know 3 options:



  • We have used maven. Profiles for this in the past, but they have the disadvantage that the release maven plugin does not work with profiles, so we had to manually change versions and were unable to deploy artifacts to a remote repository like nexus.

  • Another option is mavens assembly-plugin. As far as I know this can be used in conjunction with a release plugin.

  • We decided to write a simple tool that modifies war files after the maven build process. He works in a separate Jenkins-Job. The idea is that creation and customization are two separate steps. Artifacts coming out of maven are always in default configuration. And if we need a configuration for production release, we start jenkins which does the configuration of war files.

+2


source







All Articles