Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Tuesday, May 3, 2011

Continuous Integration for ADF applications using Hudson

This post is to show how to create a new job in hudson to setup continuous integration for an ADF application source controlled using svn and hosted on a standalone weblogic server.

Installation of hudson is very simple. Just download the latest version war file from http://hudson-ci.org/ and drop this war in your favorite server container. I am using Tomcat 7 currently.

For this blog post I am assuming following things:

  • You already have a standalone weblogic server setup and capable to run a ADF application.
  • You have the source code of your application version controlled using svn.
  • You have a running hudson with administrator privileges
So, here are the detailed steps to create and configure a job in hudson which will pull the source code from the svn repository when there are any changes committed to it and build n deploy the same code to the running standalone wls.

From the hudson dashboard click on New Job link



On next screen choose the first option free style software project for our job  and give a suitable name the job as shown below

On pressing ok will take you to detailed configuration of the job. This is a big page with a lot of options. So, I am giving a walk-through section via section. In the first part, fill job description and click on 'Discard old builds' checkbox. Here, you can specify how many old builds you want to keep to save the server space as shown below:

You can leave rest of the options and can explore on your own as they are self explanatory. Move down to the 'Source Code Management' section where we will configure the adf source code to pull and build it to deploy.

On choosing subversion, section will expand and ask for repository url which it will check for the validity. Rest of the options can be left default as they are good to go. In the next section, you need to configure at what frequency the builds should happen. Two typical options are polling svn and building periodically. You can choose both for the same job and it totally depends on individual's need. I have below used scm poll which will check for changes in the repository every 5 min.

Other schedules can be configured similarly and well explained in the question mark on the top right corner of the schedule box. So till here, your job is ready to pull the code from svn repo as soon as new changes are there. After this, next steps is to write a small script to build a ear from this code and then deploy it to the running standalone server.  For this click on the list in the build section and choose 'Execute Shell' option. This will provide a text box to write a shell script. You can either write the script here itself or write on the machine where hudson is running and just provide the path here like: /home/username/buildScript.sh as shown below:


I am providing the complete script which can be used to build the ear and deploy it to the running standalone wls with just replacing repo, server urls etc here. Just copy paste it to above text box or store it as a script in your machine and provide the path. Finally there are some post build steps which are like sending email notifications, publishing results etc. Hudson provides a large array of plugins to use for this purpose.







8 comments:

Juan José Rodríguez said...

Hi Vivek,

Thanks for the post. Just a question, It is also required to have installed JDeveloper in the same server?

Unknown said...

No Juan it is not needed jdeveloper to be installed. Only standlalone wls where you want to deploy the app after build should be accessible by hudson script.

DeCappa said...

"I have below used scm poll which will check for changes in the repository every 5 min."

Your polling entry of:
5 * * * *

Will actually only poll once an hour at 5 minutes past the hour.

You want:
/5 * * * *

That will poll the repo every 5 minutes.

Also, it is not hard to set up a post-commit hook script in subversion to post back to Hudson that an update has happened to the svn repo:
http://wiki.hudson-ci.org/display/HUDSON/Subversion+Plugin

Unknown said...

Well to correct further it is actually:

*/5 * * * *

Anonymous said...

Well done, my essay was a real success among tutors. I am so satisfied with your work.

Alexandr Sokolovski said...

http://adfpractice-sokol.blogspot.com/2012/06/adf-application-jenkins-websphere.html

Unknown said...

Hi Vivek,
I am going to use Hudson for CI our webapp developed using Oracle ADF. I wrote an ojdeploy script to make the .ear file. My WLS server is in Windows machine. Can I use your shell script to deploy my .ear to WLS or should I have to write a batch file in order to do that? Please give me an idea.

Regards !
Sameera

Unknown said...

Sameera

It depends upon where your hudson is running. the script needs to be accessible to the hudson. so if your hudson is on a linux environment then you can use shell scripting otherwise you will need to write windows compatible script.

doing that is also easier. ojdeploy commands run as it is. you just need to take of env variable setting and paths etc which are different in windows and linux