When you are building and deploying servicebus or soa composites to the server, you will have the certain dependencies with the server such as datasources or JMS resources. Those resources must be there if you want to deploy. A best practice is of course to script these. You can use WLST to run .py script which create your resources. The only problem is you want to know for sure the resources are there?! If you want to be consistent in your roll-outs on Dev, Tst, Acc and Prd, you all want to do this in the same manner. Operations usually do the roll-out on Acc and Prd but how do make sure we do this in the exact same way in Dev and Tst?
If you are using a build pipeline using Jenkins (see here and here ) you can easily add a step in there which can create the resources for you by running a script. How do we do this?
We are going to make use of the weblogic-maven-plugin. See here for the documentation. First make sure you have installed the plugin into you local repository. As the documentation says, do the following:
- Change directory to ORACLE_HOME\oracle_common\plugins\maven\com\oracle\maven\oracle-maven-sync\12.1.3
- mvn install:install-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar
- mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=c:\oracle\middleware\oracle_home\
You can check if it was successful by running
mvn help:describe -DgroupId=com.oracle.weblogic -DartifactId=weblogic-maven-plugin -Dversion=12.1.3-0-0
This should list all 24 goals of the plugin.
Now for the simple test, I have created a simple script test.py which adds a queue to the SOAJMSModule
try: print('--> about to connect to weblogic') connect('USERNAME','PASSWORD','t3://localhost:7001') print('--> about to create a queue ' + "MyQueue") edit() startEdit() cd('/JMSSystemResources/SOAJMSModule/JMSResource/SOAJMSModule') cmo.createQueue("MyQueue") cd('/JMSSystemResources/SOAJMSModule/JMSResource/SOAJMSModule/Queues/' + "MyQueue") set('JNDIName', 'jms.myqueueu') set('SubDeploymentName', 'SOASubDeployment') save() print('--> activating changes') activate() print('--> done') except: print('Failed connecting to server')
I created a simple .pom file which only defines the build plugin:
4.0.0 nl.redrock ResourceService 1.0 jar com.oracle.weblogic weblogic-maven-plugin 12.1.3-0-0 /fmwhome/wls12130 wls-wlst-server post-integration-test wlst-client true
Now lets see if we can run the script by running the following:
mvn com.oracle.weblogic:weblogic-maven-plugin:wlst-client -DfileName=test.py
As you can see, the script was ran successfully:
and to be sure we can check in the console:
And if you incorporate it into your Jenkins build pipeline, it could look something like this:
So this is an easy way to consistently run scripts through-out your DTAP.
Some considerations though:
- As you are running the script every time you are building a component, make sure the script takes in account that the resources might already have been created
- The creation of some resources require a server restart. You can also restart servers using the weblogic plugin but I’m not yet sure what a good way of working is here