Wednesday, 23 March 2011

Continuous Integration with Hudson

This blog will give you clear idea on automated deployment of SOA projects from subversion.Here is the scenario in brief,

Developed the code using Jdeveloper –> Checked in subversion –> Hudson will poll in subversion repository for any change –>On any change it will build and deploy the code in SOA server without any manual intervention –> After deployment status mail will be sent to the group.

To achieve that you have to follow couple of steps,

  1. Installing Hudson to your SOA server.

You can download hudson.war file from http://hudson-ci.org/.

In the directory where you saved hudson.war create a new directory called WEB-INF and inside that a file called weblogic.xml.  Here is the contents for the file:

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app
xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
<container-descriptor>
<prefer-application-packages>
<package-name>org.apache.*</package-name>
<package-name>org.dom4j.*</package-name>
</prefer-application-packages>
</container-descriptor>
</weblogic-web-app>

Now you need to add this file into the hudson.war using the following command:

# jar uvf hudson.war WEB-INF/weblogic.xml
Login to weblogic console and deploy the war file pointing soa_server as target.
Now the hudson page should be accessible by,
http://<host>:<port>/hudson.

Just click on enable auto refresh on top right corner.


2. Configure your Gmail account (can be any account) in your SOA server


You need to download openssl from http://www.openssl.org/related/binaries.html site.


Get gmail certificate by issuing openssl s_client -connect smtp.gmail.com:465 > smtp.cert command.


Edit smtp.cert remove everything except the :
—–BEGIN CERTIFICATE—–
<certificate>
—–END CERTIFICATE—–


Import the certificate into a new trust store by keytool -import -alias smtp.gmail.com -keystore trusted-certificates.jks -file smtp.cert.


Edit setDomainEnv.cmd, replace the existing javax.net.ssl.trustStore property setting with “-Djavax.net.ssl.trustStore=<path>/trusted-certificates.jks -Djavax.net.ssl.trustStorePassword=<password you used>” like in my case,


set EXTRA_JAVA_PROPERTIES=%EXTRA_JAVA_PROPERTIES% -Dsoa.archives.dir=%SOA_ORACLE_HOME%\soa -Dsoa.oracle.home=%SOA_ORACLE_HOME% -Dsoa.instance.home=%DOMAIN_HOME% -Dtangosol.coherence.clusteraddress=227.7.7.9 -Dtangosol.coherence.clusterport=9778 -Dtangosol.coherence.log=jdk -Djavax.xml.soap.MessageFactory=oracle.j2ee.ws.saaj.soap.MessageFactoryImpl -Dweblogic.transaction.blocking.commit=true -Dweblogic.transaction.blocking.rollback=true -Djavax.net.ssl.trustStore=C:\shrik\Oracle\fmw\user_projects\domains\base_domain\config\fmwconfig\trusted-certificates.jks -Djavax.net.ssl.trustStorePassword=changeit


Bounce the server.


Go to em,


image


and enter the following properties accordingly,


image


Then go to workflow notification property and set the notification mode email with proper from address,actionable address and reply to address.


image


Bounce the server once again and go to manage hudson from the left menu.


image


Then click on configure system and go to E-mail notification section and give all the values accordingly,


image


Click on test configuarion and you should get a test mail in your account.


3. Setting up version control system


I downloaded subversion server and client but you can download any CVS or other repository as well.


For testing purpose I would recommend VisualSVNServerManager at http://www.visualsvn.com/server/ and tortoise svn client at http://tortoisesvn.net/downloads.html .


In your ant deployment folder find the executable batch file will be picked up by Hudson for build and deployment if any change occur in the repository in my case its deployAll.bat,please check http://shrikworld.blogspot.com/2011/03/deploying-soa-11g-application-using-ant.html


You may need to copy ant-contrib.jar file from <fmw_home>\modules\net.sf.antcontrib_1.1.0.0_1-0b2\lib folder to Jdeveloper’s and SOA server’s <AntHome>/lib directory.



4. Create a JOB in Hudson


Go to http://shreekanta-pc:7001/hudson/ and click on create a new job on left menu,


image


Now click on the job and go to the configure section from left menu.


In the source code management you need to provide your repository URL like,


image


In Build Trigger select poll SCM and put ***** in schedule so that Hudson will poll SCM in every minute for any change.


In the Build section fill all as below,


image


In Post Build section give your account name accordingly,


image


Click on Save and enable auto refresh.


image


Change/Add any file in your subversion and Hudson will pick up and deploy the code into SOA server.


After that it will sent the status mail as per your account configuration.

1 comment:

Steve Djajasaputra said...

Nice article, please see also:

http://soa-java.blogspot.nl/2011/12/maven-and-hudson-jenkins-for-oracle-osb.html