Deploy MQ on CP4I using Jenkins

Kok Sing Khong
5 min readDec 17, 2021

--

Jenkins is a very popular CI/CD tool that allows you to provision applications. In this tutorial, I will show you how to deploy an MQ queue manager, which its configurations to an Red Hat Openshift (using the MQ operators that comes with Cloud Pak for Integration).

Before you begin, you must have the following setup

  • Red Hat OpenShift cluster installed (my version is 4.8.21)
  • Cloud Pak for Integration installed on the OpenShift cluster (my version is 2021.3.1)
  • Github account
  • Clone this repository (https://github.com/khongks/mq-pipeline.git)
MQ Jenkins Pipeline

Install Jenkins on Red Hat OpenShift (from the Openshift Console)

  1. Create a project called jenkins.
  2. From the Operator Hub, install jenkins-operator provided by Red Hat in the jenkins namespace. Wait for installation to complete.
Jenkins Operator tile

3. From the jenkins-operator, create a Jenkins instance. Give a name to your instance (e.g. jenkins-kks). Wait for installation to complete.

4. To access the Jenkins console, get the route using the following command in a terminal.

oc get route -n jenkins jenkins-jenkins-kks -ojson | jq -r .spec.host

You should have the URL for the Jenkins console that looks like this:

jenkins-jenkins-kks-jenkins.<domain-name>

Create a credential in Jenkins to store IBM entitlement key (from Jenkins Console)

  1. Click on Manage Jenkins > Manage Credentials
Manage Credentials icon

2. Click on Jenkins (global) > Global credentials (unrestricted)

3. Click on Add Credentials, with the following setup.

Add Credentials

This ID is reference by the Jenkins pipeline to retrieve the value of the Secret.

Enable Jenkins service account to create objects in OpenShift (from terminal)

  1. Run this command to find the service account in the namespace
oc get sa -n jenkins

The response should be:

NAME                SECRETS AGE
builder 2 73m
default 2 73m
deployer 2 73m
jenkins-jenkins-kks 2 54m
jenkins-operator 2 56m

2. Run this command to assign cluster-admin role to the service account. I assigned cluster-admin role, to simplify the setup; but you can create a custom role with the appropriates to do this.

oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:jenkins:jenkins-jenkins-kks

Configure a pipeline to build MQ queue manager (from Jenkins Console)

  1. Click on Dashboard > New Item > Pipeline. Provide a name (e.g. mq-pipeline) and click Ok.
  2. Go to Pipeline section, specify the following and click Save.
Setup the pipeline

Perform test build (from Jenkins Console)

  1. Click Build Now.
  2. Click Build History > #1 > Console Output
  3. When the pipeline is completed, you should see the following output, with the MQ Console URL, with login user and password. It also generates a ccdt.json to access the queue manager.
...
Installation status: Running
MQ console URL: <<MQ_CONSOLE_URL>>
User: admin
Pass: <<PASSWORD>>
{
"channel": [
{
"name": "QM1CHL",
"clientConnection": {
"connection": [
{
"host": "<<HOST>>",
"port": 443
}
],
"queueManager": "QM1"
},
"transmissionSecurity": {
"cipherSpecification": "ANY_TLS12_OR_HIGHER"
},
"type": "clientConnection"
}
]
}
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

4. You should see the status of the completed job (#3 as follows).

Jenkins build dashboard

Test the deployed queue manager (from terminal)

  1. Clone the git repository
git clone https://github.com/khongks/mq-pipeline.git

2. Go to the folder mq-pipeline/test and update the file ccdt.json.

3. Put a message.

./mq-put.sh
Sample AMQSPUT0 start
target queue is APPQ
TESTING

4. Get the message

./mq-get.sh
Sample AMQSGET0 start
message <TESTING>

Configure Jenkins pipeline to be triggered from GitHub events

(From the Github web)

  1. Go to this Github URL to add a webhook
https://github.com/{GIT_ORG}/mq-pipeline/settings/hooks/new

2. Configure Payload URL and Content type

  • Payload URL: https://<jenkins-route-hostname>/github-webhook. You can obtain this value from previous step
  • Content type: application/json
Webhook configuration

3. Select event types that triggers this weekhook.

Webhook events preference
  • Pushes
  • Pull requests

4. Finally, click on Add webhook to create the webhook.

(From Jenkins console)

5. Click Configure > Build Triggers and check GitHub hook trigger for GITScm polling. Click Save.

Github Build Triggers

6. To test, make a change in the config.mqsc.tmpl file and push the changes into Github repository.

7. Note that build job is triggered in Github.

Github Webhook recent deliveries

and in Jenkins.

Jenkins build dashboard

Hopeful you enjoy this tutorial. Merry Christmas and Happy New Year!

Disclaimer:

All opinions expressed here are very much my own and not of IBM. All codes/scripts/artifacts are provided as-is with no support unless otherwise stated.

--

--

Kok Sing Khong
Kok Sing Khong

Responses (2)