If you have Oracle OSB 11.1.1.7.0 or higher this document will help you to automate the compilation process for OSB at project level.

Pre-requisites (what I have installed in my environment “for Linux it’s the same, just change the installers and use the <.sh> scripts instead <.bat> ones.”)

We won’t need OEPE to compile, but is a pre-requisite to install OSB which we need.

Manual execution of ConfigJar

After installing those components, you’ll find out a directory in your OSB home: {Oracle_OSB}\tools\configjar

There is a tool called “configjar.bat” which requires to work that you run the “setenv.bat” you should see a directory like this:

configjar directory's content.

configjar directory’s content.

In order to use configjar, you’ll have to:

  • Run setenv.bat
  • Have an project or resource level xml of your project
  • Run configjar.bat with that xml

This is a project level xml example, this means we’ll generate a JAR for a whole project:

If you want to generate OSB jars with your command line, project level, using ANT or even at resource level here’s the whole guide of Oracle and here are all the XML examples you may need.

In the previous xml example, we export one project with “no dependencies”, in case you need to include dependencies then change “includeSystem” to “True”.

Automating the process with Python and Jenkins

This is just a part of my main script to perform the compilation task but it serves as a good example.

Basically the script has a couple of variables to complete the paths for each OSB project. The script will create the xml files required for configjar.bat by redirecting the standard output to a file.

Finally the python script calls a sub-shell process to invoke the configjar.bat with the “-settingsfile” paramenter and the xml filename.

Because configjar.bat requires setenv.bat I modified the configjar.bat to call it:

Setup in Jenkins

Once I was able to run the python script manually I just need to call the script in python and it will perform the compilation. Also I’ve added a parameterized option to pass the branch from which I want to compile:

And some GIT paramenters to fetch the branch of course.

Also I gave the project a defined workspace and an specific node to run improving the performance of this and other tasks in our Jenkins server:

Finally in the Build step of your project add an “Execute Windows Batch command”: