Presently, I have many jenkins jobs deploying war files to multiple servers using jboss as maven plugin. I have created multiple post build maven goals to deploy to multiple instances. To enhance the setup, I need to read the data from a SQL table where the mapping exist for each project and instances. Based on the data, I need to dynamically change the instances(undeploy from previous instance and deploy on new instance) and do hot deployment. Any thoughts?
Instead of using DB, I would suggest you to use a simple source repo, e.g. git repo. You can have such mapping data in that file.
So when you do deployment, Jenkins would checkout the repo. Your script could read it and do deployment. The script could be bash, ruby or anything you think it's easy. The script for deployment could be put into the same source repo as well.
Later on, if you need to do any change, you just change the repo and push the change.
The whole idea is infrastructure as code. You should put everything into source control. Jenkins will be a single tool to invoke the script from your source repo.
Related
According to this excellent article from Martin Fowler:
Once the build finishes successfully, the CI server packages the build artifacts and publishes them. These build artifacts contain the database migration scripts, so that they can be applied to the databases in downstream environments (...)
My question is how this is realized in practice for Java-based workflow? Build artifacts are normally .war, .jar or .ear files, and are published to Nexus, Archiva or Artifactory server. Can migration scripts be included in these artifacts, so that migration can be performed without any modification to target environments? Can tools like Flyway or Liquibase be used for this purpose?
Yes! We (Flyway) strongly recommend packaging your migrations with your application and running them on startup. This way you ensure that your database always contains the objects (tables, views, stored procedures, ...) the current version of your application expects.
We use maven for building artefacts and we have flyway migration scripts under the src/main/resources/db/migration folder.
App is a spring web app and during spring container startup, it runs Flyway migrate. If there is a problem, the app never starts.
This way we ensure that database state is what the app needs when it starts.
we are implementing Maven + Jenkins and we are trying some artifact repositories like Artifactory. We now are deploying with svn -yes, it's awful- so we have a lot of requirements from our clients that should be done instantly, like "please add this button to my js form" so for now is enough commiting JS file and updating that on client deployed Tomcat.
I need to know if there is a way in Maven to install in a server just an incremental part of our deployable files, because the complete war file has about 600MB and it is not viable to download all the war file for a little change of two lines in javascript.
Now we can create a new artifact in each commit, but we cannot understand if it will be possible to achieve a continuous delivery that allow us to send a instant fix to a client server.
All the examples that we saw are referred to deployable artifacts, but there isn't a case in which someone use somethind like mvn install -mySpecificVersion and only the changed files are downloaded, or something similar.
Thanks.
After months of thinking in solutions we figured out that the solution is modules in our project, so the dynamism and instant-fix requirement are related to the core or specific little module. This approach will drive us to a reproducible pipe line and a cheap transfer of data.
I currently have a Jenkins instance installed on a Development box. This builds fine and deploys to our development environment without any issues.
During the build process my project makes use of a single properties file containing details such as a database connection URL (Details such as these will obviously vary depending on the environment I'm pointing to).
What I would like to know is what is the best way to configure my project so that when I want to release to Production the WAR file built by Jenkins contains the Production properties instead of Development?
(Note I am also using Maven in my project).
I know 3 options:
We have used maven.-profiles for that in the past, but they have the disadvantage, that the release-plugin of maven doesn't work with profiles, so we had to change the versions manually and were unable to deploy the artifacts in a remote repository like nexus.
Another Option is mavens assembly-plugin. That can be used together with the release-plugin, as far as I know.
We decided to write a simple tool that changes the war-files after the maven-build process. It runs in a seperate Jenkins-Job. The Idea is, that building and configuring are two seperate steps. The Artifacts comming out of maven are always in a default-configuration. And if we need the configuration for the production release we start a jenkins job that does the configuration of the war-files.
You can create different maven profiles, like dev, prod, then in the profile setting, use/filter the corresponding resource files like .../(dev|test|prod)/project.properties And in Jenkins, when you build for different platform, build with -Pdev or -Pprod to get the war for the right target.
You may want to check maven profile, maven resource filtering for detailed configuration.
something not related, connect Database via jndi if possible.
What is the 'best practice' way of separating Maven deployment configuration from the build config?
I have a war project, that is built by Jenkins. I'd like Jenkins to deploy this to Elastic Beanstalk, but alas the best solution available at the moment is to use the beanstalk-maven-plugin.
I'm not sure it makes sense for the POM.xml to include information about deployment; after all, at build time that .war could end up anywhere.
In this situation, is there some way of using Maven modules to store the beanstalk-maven-plugin config in a separate POM to that of the actual software project?
I think you have to solutions.
Just add the beanstalk-maven-plugin definition to your regular pom.xml. The configuration can be stored in separate properties file or provided via system properties in command line (-D option). Add beanstalk goal to command line of maven in Jenkins. So, each build will be deployed on beanstalk. Alternatively you can define yet another project in Jenkins that just runs the deployment without compilation. You can run this deployment project on scheduled basis or via projects dependencies in Jankins.
Create yet another maven project. It will just run beanstalk plugin. I personally do not see serious advantages to do this.
I think about three things:
a. I'm not sure (I'm admit I was a bit busy trying to come up with 0.2.7-RC7), but I think the Elastic Beanstalk Configuration Files are supported in Java.
So it perhaps could be a good idea to separate (I admit managing config in Beanstalker is Boring)
b. Another option is using war overlays in maven-war-plugin's overlay feature, and create a war which depends on your other war.
In my personal case, if you ask, I do have a separate deployment profile in Maven, and that feature often come in handy
I have almost no experience in using netbeans and svn so please correct me gently if I am wrong. I come from using python/vim/git so workflow wise is foreign to me.
Currently, I used the Netbeans' svn plugin to checkout my project from a remote repository. The project has several components like webservices, and also a swing client and of the business logics.
Assuming that I need to work with the web services and the swing client, do I create separate projects for each, and import the project as references?
Finally, currently I'm using netbeans to test the webapp on the local glassfish server. How do I deploy on a remote test server so that my team mates can use and test the web app?
If all of the seperate components are a part of the same project in svn then, no, you should only create one project in netbeans. Check out the project from svn and once netbeans has checked out the project it should prompt you to create a netbeans project when it does select project from existing sources, follow the wizard steps and your project will be created. You will have to import any external jars needed by the project that has been checked out into the newly created project in netbeans. NOTE: Netbenas will create a build.xml file for the newly created project so be sure that you do not commit that build.xml file into the repository unless it's needed.
To setup a remote server in netbeans go to tools->servers, select add server, select the server type(glassfish, tomcat, etc) then enter the pertinent information for the server using the wizard.
First question "Assuming that I need to work with the web services and the swing client, do I create separate projects for each, and import the project as references?"
It really depends on your architecture - how coupled are those components. It's also important what packaging system do you use? For example if you use Maven you can easily modulate the project and define dependencies between the modules. Check out this for details. I am referring to maven as it's build-in in Netbeans.
Regarding your testing you basically have 2 options:
a) expose your glassfish to your buddies
b) package and deploy your project remotely - this really cannot be given straight answer - depends on your infrastructure, where's the remote server, how big the deployment package is, how the application server behaves regarding hot deployments etc.
I suggest try the first option.
SVN helps you to keep the project in several versions in the repository.
You can always checkout from repository.
once you checked out, you will be using the project from a saved directory somewhere in your local machine.
Now, you can keep on developing the project, at the same time your friends can also keep doing that, and whenever you think you have done enough changes or development then after verifying your own copy of the project, you can commit the changes to repository.
After committing the changes will be visible in the repository to everyone, and hence anyone can access this updated version of the project residing in the repository.
Note that the earlier version will not be deleted, unless you do so.
Your friend can also checkout a copy of the project from the repository and they can merge it with their existing ones, and they can also commit the changes.
and at the same time, you can ask your friend to check your developed code by checking out the project and deploying on their local server.
I hope it gives you a better picture.