WMB Continuous Integration

Godfrey Menezes
13 min readOct 2, 2020

Install Apache Tomcat

Download the installable for Apache Tomcat from the following location — http://tomcat.apache.org/download-70.cgi .

We are using the 7.0.42 version for this and it can be downloaded from — http://mirror.cc.columbia.edu/pub/software/apache/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42-windows-x64.zip

Extract the archive file and place it in local directory. In our case we have it in the ‘c:\IBM\’ directory.

To start apache tomcat java is needed. If java is not installed on the machine and you try to run ‘startup.bat’ from the bin directory it would give the following error.

Directory Structure

JAVA_HOME is not set up

Download and install java from the location — http://www.oracle.com/technetwork/java/javase/downloads/index.html . We have the JDK and JRE installed in ‘c:\java’ directory.

After java is installed create the JAVA_HOME variable pointing to c:\java\jdk directory as follows -

Set up the JAVA_HOME environment

Save it and now if you start apache tomcat it will work as follows.

Apache Tomcat started

Install Apache Ant

The next step would be to install Apache Ant that allows us to script creation and deployment of bar files. Download the installable for Apache Ant from the following location — http://ant.apache.org/ .

We are using the 1.9.2 version for this and it can be downloaded from — http://apache.mirrors.tds.net//ant/binaries/apache-ant-1.9.2-bin.zip

Extract the archive file and place it in local directory. In our case we have it in the ‘c:\IBM’ directory as shown in Fig.1

  • Create Ant Build File to create BAR file

Under the assumption that we have a WMB application project ‘MFA_TestAppln’ in the ‘c:\IBM\workspaces\IIB9’ workspace, create the XML file that would be the input to the ant executable for creation of the bar file. The XML describes below how to create and deploy a bar file for ‘MFA_TestAppln’.

<?xml version="1.0"?>
<project name="project" default="run">
<target name="run" description="">
<property name="toolkit.home" value="C:\IBM\IntegrationToolkit90" />
<property name="workspaces.dir" value="C:\IBM\workspaces\IIB9" />
<property name="runtime.dir" value="C:\IBM\MQSI\9.0.0.0\bin" />
<property name="appln.name" value="MFA_TestAppln" />
<property name="bar.name" value="${workspaces.dir}\${appln.name}\${appln.name}.bar" />
<antcall target="mqsideploybar" />
</target>
<! -- Target to build the broker archive using mqsicreatebar -->
<target name="mqsicreatebar.buildbar">
<echo message="Building Broker Archive file: ${bar.name} " />
<exec executable="${toolkit.home}\mqsicreatebar.exe" spawn="false">
<arg value="-data" />
<arg value="${workspaces.dir}" />
<arg value="-b" />
<arg value="${bar.name}" />
<arg value="-a" />
<arg value="MFA_TestAppln" />
</exec>
<echo message="Completed building Broker Archive file - ${bar.name} " />
</target>
<! - -Target to deploy the broker archive using mqsideploybar-->
<target name="mqsideploybar" depends="mqsicreatebar.buildbar">
<echo message="Deploying Broker Archive file: ${bar.name} " />
<exec executable="${runtime.dir}\mqsideployscript.bat" spawn="false">
<arg value="${Brokername}" />
<arg value="-e" />
<arg value="${execution.group}" />
<arg value="-a" />
<arg value="${workspaces.dir}\${appln.name}\${appln.name}.bar" />
</exec>
<echo message="Completed building Broker Archive file - ${bar.name} " />
</target>
</project>

We have the above script saved in following location — ‘C:\IBM\workspaces\IIB9\MFA_TestAppln\build.xml’ . Before we run this ant script we need to make a small change to ‘C:\IBM\MQSI\9.0.0.0\bin\mqsideployscript.bat’. Change the ‘call’ to ‘echo’ and add the second line and save the file.

– — — — — — — — -@echo mqsisetmqenv@call “C:\IBM\MQSI\9.0.0.0\bin\mqsiprofile.cmd”– — — — — — — — -

Run the above saved build.xml file by passing it to ant and passing the arguments as follows -

C:\IBM\apache-ant-1.9.2\bin>ant -buildfile C:\IBM\workspaces\IIB9\MFA_TestAppln\build.xml -DBrokername=WBRK9 -Dexecution.group=default -v

Where Brokername is the local broker on the machine and execution.group is the EG on the broker WBRK9. It would create a bar file ‘C:\IBM\workspaces\IIB9\MFA_TestAppln\MFA_TestAppln.bar’ and deploy to WBRK9 broker’s EG default.

Bar File deployed to Broker

Install Jenkins

Now that we have the Ant script ready the next step would be to run in using a web interface that allows automated deployment with just a click of a button without installing it locally. To do this we use Jenkins. Download the WAR file to run Jenkins from Apache Tomcat from the following location — http://mirrors.jenkins-ci.org/war/latest/jenkins.war

Copy the downloaded war file and place it in the webapps directory and re-start apache tomcat. This will load the jenkins in the servlet container. The command window will display the info when Jenkins is loaded -

Jenkins up and running

In the browser enter the URL -http://localhost:8080/jenkins/ — and you should be able to see the following screen -

Jenkins web interface

Click ‘Manage Jenkins’ on left hand top corner to configure Jenkins to use Ant and also Java. Next click the first option ‘Configure System’. Enter the details as shown below and save it.

Configure Jenkins with Ant and Java

Next click the ‘New Job’ link on the right hand top corner to open the interface to create a job to run the Ant Script. Give the job a name-in this scenario MFA_Test- and select the first option ‘Build a free-style software project ‘ and save.

In the build section, click on ‘Add build step’ and select ‘Invoke Ant’.

Specify the build step

Enter the details of the job for Build File and Properties. The build file is the same what we have used from the preceeding i.e. C:\IBM\workspaces\IIB9\MFA_TestAppln\build.xml and the properties are the values we supply to the build file.

Brokername=WBRK9

execution.group=default

Click to save the job.

Ant job properties

The interface would look like this -

Ant job overview

Click on ‘Build Now’ to initiate the building of bar file and deployment to the broker.

Ant job running

If the job runs successfully it will show a blue color beside the job run as well as the time at which it was run. Clicking it on the time will show the verbose details.

Console output indicating the job ran successfully

Securing Jenkins

It is imperative that Jenkins will be used by the developers to run tasks. To control the access setup security access by ‘Manage Jenkins’ and ‘Configure Global Security’. Select ‘Enable Security’ to show the options. In ‘Security Realm’ select ‘Jenkin’s own user database’ with the ‘Allow users to sign up’ checkbox selected. In ‘Authorization’ select ‘Matrix-based security’. Add a user with user id and give him the requisite permission and click ‘Save’.

Configure Global Security

As soon as you save it will bring you to login screen. Select the ‘Create an account’ and enter the details and click on ‘Sign up’. This will create the user and give him the permissions. Please be aware that once you click on save you will be thrown back to login and cant access. The only way out is reconfigure.

User sign up

Working with SVN as source repository

Before we start working with SVN we need to integrate our toolkit with a SVN Server using an Eclipse SVN plugin. To do so download the plugin for Eclipse by selecting ‘Help’, ‘Install New Software’. Click ‘Add’, give the location a name -in our case ‘SvnEclipse’- and point to the Location ‘http://subclipse.tigris.org/update_1.10.x ‘ and click ‘OK’.

Add the SubEclipse site

This will list the site to download the plugins. Select both the options and click ‘Next’. The download will begin.

Add the SubEclipse site

A confirmation of what we are downloading.

SubEclipse Install Details

Accept the license.

Download begins.

Software begins installation

Accept the warning for unsigned content download.

Accept security warning

Restart the toolkit.

After the restart of the toolkit you will see the following addition in your perspective list

SVN Repository Exploring Added to Perspective

Open the ‘SVN Repository Exploring’ perspective. Right click on white canvas and select ‘New’ and ‘Repository Location’ to add the repository location for the SVN Server versioning location.

Add the SubEclipse site

Enter the URL of the SVN repository and select finish.

Add the SVN Repository site

It will list the repository and the artifacts in the repository.

SVN repository listed

To share the project in SVN repository right click the project and then select ‘Team’ and then ‘Share Application’.

Share the project in SVN

It will pop up for the application to be shared in SVN. Select the Project/Application, ‘Team’ and ‘Share Project’

Share the project

Select ‘SVN’ and click ‘Next’.

SVN Repository

Select the existing repository and click ‘Next’.

Select SVN Repository

Select the existing repository and click ‘Next’.

Share Project with Project Name

Click finish to share the project in the repository and click ‘No’ to not open the repository just yet. Notice that the project has a black star against it.

Project Name has a new icon beside it

Click finish to share the project in the repository and click ‘No’ to not open the repository just yet. Notice that the project has a black star against it.

Commit the project

Click finish to share the project in the repository and click ‘No’ to not open the repository just yet. Notice that the project has a black star against it.

Commit the Project to SVN

Click finish to share the project in the repository and click ‘No’ to not open the repository just yet. Notice that the project has a black star against it.

Comment the changes

Click finish to share the project in the repository and click ‘No’ to not open the repository just yet. Notice that the project has a black star against it.

Project committed to SVN

Building bar file by accessing the code from SVN repository

Till now we had been creating the bar file from the workspace, but ideally the bar file should be created by getting the latest copy from SVN and then create the bar file for deployment. To do that, get the svnant that includes the SVN library files that would allow us to connect and checkout code from SVN.

Download the following archive file -http://subclipse.tigris.org/files/documents/906/49042/svnant-1.3.1.zip- and extract jar files — svnant.jar, svnClientAdapter.jar and svnjavahl.jar — to the lib directory of the Ant installation i.e. ‘C:\IBM\apache-ant-1.9.2\lib’.

We will use these files from our ANT script to connect and retrieve the code. To prevent overwriting the build.xml file we have in MFA_TestAppln by fetching the latest from SVN we move the file to a local directory in our case we move it to ‘c:\personal\development\build.xml’. Change the build xml file location on the job as follows.

Change the build.xml location

Note:- We have set the verbose option on this job by having ‘-v’ in the Targets to read how the job works through.

Based on the location of MFA_Appln change the property for ‘Source Code Management’ from ‘none’ to ‘Subversion’ and set the properties as follows –

Repository URL — https://localhost/svn/WMBRepo/MFA_TestAppln

Keep the other properties as default.

Project committed to SVN

Click on the blue question mark against ‘Repository URL’ and it will list the following text–

Specify the subversion repository URL to check out, such as “http://svn.apache.org/repos/asf/ant/". You can also add “@NNN” at the end of the URL to check out a specific revision number, if that’s desirable. This works for Subversion Revision Keywords and Dates like e.g. “HEAD”, too.
When you enter URL, Jenkins automatically checks if Jenkins can connect to it. If access requires authentication, it will ask you the necessary credential. If you already have a working credential but would like to change it for other reasons, click this link and specify different credential.
During the build, revision number of the module that was checked out is available through the environment variable SVN_REVISION, provided that you are only checking out one module. If you have multiple modules checked out, use the svnversion command. If you have multiple modules checked out, you can use the svnversion command to get the revision information, or you can use the SVN_REVISION_<n> environment variables, where <n> is a 1-based index matching the locations configured. The URLs are available through similar SVN_URL_<n> environment variables.

Click on the ‘this link’ hyperlink to enter the credentials to login to SVN.

Credentials for the job

Click on ‘OK’, if the credentials are right the screen will display the following message ‘Authentication was successful. Information is stored in Jenkins now.’. Click on ‘Close’ and it will close the credentials window. Click on ‘save’ to save the job.

Now we need to change the build.xml to use the svn details and credentials mentioned in the job as well as get the code from SVN. The text highlighted in yellow is what we have added to the earlier build.xml.

<?xml version="1.0"?><project name="project" default="run"><target name="run" description=""><! - SVN Properties →<property environment="env" /><property name="svn.base.url" value="${env.SVN_URL}" /><property name="svnant.lib.dir"location="c:\ibm\apache-ant-1.9.2\lib" /></target></project>

<?xml version=”1.0"?>

<project name=”project” default=”run”>

<target name=”run” description=””>

<! — SVN Properties →

<property environment=”env”/>

<property name=”svn.base.url” value=”${env.SVN_URL}” />

<property name=”svnant.lib.dir” location=”c:\ibm\apache-ant-1.9.2\lib” />

<property name=”svnant.javahl” value=”false” />

<property name=”toolkit.home” value=”C:\IBM\IntegrationToolkit90" />

<property name=”workspaces.dir” value=”C:\IBM\workspaces\IIB9" />

<property name=”runtime.dir” value=”C:\IBM\MQSI\9.0.0.0\bin” />

<property name=”appln.name” value=”MFA_TestAppln” />

<property name=”bar.name” value=”${workspaces.dir}\${appln.name}\${appln.name}.bar” />

<path id=”path.svnant”>

<pathelement location=”${svnant.lib.dir}\svnant.jar” />

<pathelement location=”${svnant.lib.dir}\svnClientAdapter.jar” />

<pathelement location=”${svnant.lib.dir}\svnjavahl.jar” />

</path>

<typedef resource=”org/tigris/subversion/svnant/svnantlib.xml” classpathref=”path.svnant” />

<antcall target=”mqsideploybar” />

</target>

<! — Target to get the code from SVN →

<target name=”getSVNCode”>

<svnSetting

javahl=”false”

svnkit=”false”

id=”svn.settings”/>

<svn refid=”svn.settings”>

<checkout url=”${svn.base.url}”

destPath=”${workspaces.dir}\MFA_TestAppln” revision=”HEAD” />

</svn>

</target>

<! — Target to build the broker archive using mqsicreatebar →

<target name=”mqsicreatebar.buildbar” depends=”getSVNCode”>

<echo message=”Building Broker Archive file: ${bar.name} “ />

<exec executable=”${toolkit.home}\mqsicreatebar.exe” spawn=”false”>

<arg value=”-data” />

<arg value=”${workspaces.dir}” />

<arg value=”-b” />

<arg value=”${bar.name}” />

<arg value=”-a” />

<arg value=”MFA_TestAppln” />

</exec>

<echo message=”Completed building Broker Archive file — ${bar.name} “ />

</target>

<! — Target to deploy the broker archive using mqsideploybar →

<target name=”mqsideploybar” depends=”mqsicreatebar.buildbar”>

<echo message=”Deploying Broker Archive file: ${bar.name} “ />

<exec executable=”${runtime.dir}\mqsideployscript.bat” spawn=”false”>

<arg value=”${Brokername}” />

<arg value=”-e” />

<arg value=”${execution.group}” />

<arg value=”-a” />

<arg value=”${workspaces.dir}\${appln.name}\${appln.name}.bar” />

</exec>

<echo message=”Completed building Broker Archive file — ${bar.name} “ />

</target>

</project>

If there is a ‘.svn’ folder in the workspace MFA_TestAppln folder delete it. The build.xml saved lets run the job and see how it performs. If all things good it should verbose output the following on the screen –

Started by user Godfrey P Menezes

Building in workspace C:\Users\godfrey\.jenkins\workspace\MFA_Test

Updating https://localhost/svn/WMBRepo/MFA_TestAppln at revision ‘2013–09–08T17:21:06.656 -0400’

At revision 2

no change for https://localhost/svn/WMBRepo/MFA_TestAppln since the previous build

[Development] $ cmd.exe /C ‘“c:\ibm\apache-ant-1.9.2\bin\ant.bat -file build.xml -Dexecution.group=default -DBrokername=WBRK9 -v && exit %%ERRORLEVEL%%”’

Apache Ant(TM) version 1.9.2 compiled on July 8 2013

Buildfile: C:\Personal\Development\build.xml

Detected Java version: 1.7 in: C:\Java\jdk\jre

Detected OS: Windows 8

parsing buildfile C:\Personal\Development\build.xml with URI = file:/C:/Personal/Development/build.xml

Project base dir set to: C:\Personal\Development

Build sequence for target(s) `run’ is [run]

Complete build sequence is [run, getSVNCode, mqsicreatebar.buildbar, mqsideploybar, ]

run:

parsing buildfile jar:file:/C:/IBM/apache-ant-1.9.2/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/IBM/apache-ant-1.9.2/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file

[property] Loading Environment env.

parsing buildfile jar:file:/C:/IBM/apache-ant-1.9.2/lib/svnant.jar!/org/tigris/subversion/svnant/svnantlib.xml with URI = jar:file:/C:/IBM/apache-ant-1.9.2/lib/svnant.jar!/org/tigris/subversion/svnant/svnantlib.xml from a zip file

parsing buildfile jar:file:/c:/ibm/apache-ant-1.9.2/lib/svnant.jar!/org/tigris/subversion/svnant/svnantlib.xml with URI = jar:file:/c:/ibm/apache-ant-1.9.2/lib/svnant.jar!/org/tigris/subversion/svnant/svnantlib.xml from a zip file

Project base dir set to: C:\Personal\Development

[antcall] calling target(s) [mqsideploybar] in build file C:\Personal\Development\build.xml

parsing buildfile C:\Personal\Development\build.xml with URI = file:/C:/Personal/Development/build.xml

Project base dir set to: C:\Personal\Development

Build sequence for target(s) `mqsideploybar’ is [getSVNCode, mqsicreatebar.buildbar, mqsideploybar]

Complete build sequence is [getSVNCode, mqsicreatebar.buildbar, mqsideploybar, run, ]

[antcall] Entering C:\Personal\Development\build.xml…

Build sequence for target(s) `mqsideploybar’ is [getSVNCode, mqsicreatebar.buildbar, mqsideploybar]

Complete build sequence is [getSVNCode, mqsicreatebar.buildbar, mqsideploybar, run, ]

getSVNCode:

[svn] Using command line

[svn] <Checkout> started …

[svn] co — no-auth-cache -r HEAD https://localhost/svn/WMBRepo/MFA_TestAppln@HEAD C:\IBM\workspaces\IIB9\MFA_TestAppln — non-interactive

[svn] A C:\IBM\workspaces\IIB9\MFA_TestAppln\MFA_TestAppln.bar

[svn] A C:\IBM\workspaces\IIB9\MFA_TestAppln\.project

[svn] A C:\IBM\workspaces\IIB9\MFA_TestAppln\MFP_TestAppln.msgflow

[svn] A C:\IBM\workspaces\IIB9\MFA_TestAppln\build.xml

[svn] Checked out revision 2.

[svn] <Checkout> finished.

mqsicreatebar.buildbar:

[echo] Building Broker Archive file: C:\IBM\workspaces\IIB9\MFA_TestAppln\MFA_TestAppln.bar

[exec] Current OS is Windows 8

[exec] Executing ‘C:\IBM\IntegrationToolkit90\mqsicreatebar.exe’ with arguments:

[exec] ‘-data’

[exec] ‘C:\IBM\workspaces\IIB9’

[exec] ‘-b’

[exec] ‘C:\IBM\workspaces\IIB9\MFA_TestAppln\MFA_TestAppln.bar’

[exec] ‘-a’

[exec] ‘MFA_TestAppln’

[exec]

[exec] The ‘ characters around the executable and arguments are

[exec] not part of the command.

[echo] Completed building Broker Archive file — C:\IBM\workspaces\IIB9\MFA_TestAppln\MFA_TestAppln.bar

mqsideploybar:

[echo] Deploying Broker Archive file: C:\IBM\workspaces\IIB9\MFA_TestAppln\MFA_TestAppln.bar

[exec] Current OS is Windows 8

[exec] Executing ‘C:\IBM\MQSI\9.0.0.0\bin\mqsideployscript.bat’ with arguments:

[exec] ‘WBRK9’

[exec] ‘-e’

[exec] ‘default’

[exec] ‘-a’

[exec] ‘C:\IBM\workspaces\IIB9\MFA_TestAppln\MFA_TestAppln.bar’

[exec]

[exec] The ‘ characters around the executable and arguments are

[exec] not part of the command.

[exec] mqsisetmqenv

[exec] BIP1054E: The broker ‘WBRK9’ is not running.

[exec]

[exec] In order for the commandline utility to work, the broker needs to be running.

[exec]

[exec] Ensure that the broker is running and that the correct connection parameters have been supplied to the utility.

[echo] Completed building Broker Archive file — C:\IBM\workspaces\IIB9\MFA_TestAppln\MFA_TestAppln.bar

[antcall] Exiting C:\Personal\Development\build.xml.

BUILD SUCCESSFUL

Total time: 28 seconds

Finished: SUCCESS

--

--