Message Image  

App Connect

App Connect Enterprise simple CI/CD deployment using Jenkins, Git, Nexus 

Tue July 28, 2020 09:35 AM

Overview

This article will provide guidance to teams who are looking to building a simple CI-CD for IBM App Connect Enterprise (ACE) bar file deployment onto On-Prem Integration Server.

The Scenario,
1) Developer commits the ACE project into the github repository.
2) Jenkins Build job pulls ACE projects from Github repository.
3) Jenkins Build job then creates bar files and uploads them into Nexus Artifactory
4) Tags the github project with the Jenkins build number.
5) Jenkins deploy jobs downloads bar files from Nexus, and deploys to ACE Integration Servers.

Components

1) Github as source code repository.
2) Jenkins for build & deployment.
3) Nexus to store bar files.
4) Xvfb – required to run mqsicreatebar command

For this receipe I installed Jenkins, Nexus, Xvfb, and IBM AppConnect Enterprise on Redhat linux.

Installation

Jenkins Install

Jenkins install instructions,
https://wiki.jenkins.io/display/JENKINS//Installing+Jenkins+on+Red+Hat+distributions

Nexus Install

Nexus will be used as a repository to store ACE Bar files:

$ sudo mkdir /app && cd /app
$ sudo wget -O nexus.tar.gz https://download.sonatype.com/nexus/3/latest-unix.tar.gz

$ sudo tar -xvf nexus.tar.gz
$ sudo mv nexus-3* nexus
$ sudo adduser nexus
$ sudo chown -R nexus:nexus /app/nexus
$ sudo chown -R nexus:nexus /app/sonatype-work
$ sudo vi /app/nexus/bin/nexus.rc
run_as_user=”nexus”

Running nexus as a service:
sudo vi /etc/systemd/system/nexus.service
Add below lines:
[Unit] Description=nexus service
After=network.target

[Service] Type=forking
LimitNOFILE=65536
User=nexus
Group=nexus
ExecStart=/app/nexus/bin/nexus start
ExecStop=/app/nexus/bin/nexus stop
User=nexus
Restart=on-abort [Install] WantedBy=multi-user.target
========
$ sudo ln -s /app/nexus/bin/nexus /etc/init.d/nexus
$ sudo chkconfig –add nexus
$ sudo chkconfig nexus on

$ sudo systemctl start nexus
(or)
sudo service nexus start
$ sudo service nexus status
$ tail -f /app/sonatype-work/nexus3/log/nexus.log (check nexus.log to make sure the service started successfully)

Open Nexus URL,
http://nexus-server:8081
Create new repository, i created “raw (hosted)” repository, but you can use different one like Maven.
Settings > Repositories > Create Repository > raw (hosted > “generic”

The Bar files will be pushed to Nexus “repository/generic” repo.

Xvfb Install

$ sudo yum install Xvfb
Start Xvfb:
$ export DISPLAY=
/usr/bin/Xvfb :1 -screen 0 1024x768x24 &

Auto starting Xvfb during system reboot
vi /etc/rc.local
Xvfb :0 -screen 0 1024x768x24&

Jenkins Configuration

SSH to GitHub setup
On the Jenkins server,
generate ssh keypair, load the private key into Jenkins and public key to Github.com.

$ sudo su -s /bin/bash jenkins
$ cd /var/lib/Jenkins
$ ssh-keygen
This generates id_rsa, and id_rsa.pub files under /var/lib/jenkins/.ssh folder.
$ cat .ssh/id_rsa.pub

1) github.com – Add the public key,
Settings > SSH and GPG keys > New SSH Key > “jenkins-dpydalmq101” > paste id_rsa.pub contents.

2) Jenkins Url – Add the private key
> Credentials > System > Global Credentials (unrestricted) > Add Credentials > SSH Username with private key >
ID: jenkins-github
Description: Private key to connect from Jenkinks to github.com
Username: jenkins
Private Key: < paste the private key (id_rsa) content generated above.

Jenkins > Global Tool Configuration

Manage Jenkins > Global Tool Configuration > Xvfb
Note: Make sure to install Xvfb plugin before configuring.

Jenkins – Build Job

1) Logon to Jenkins Url
2) Create Free Style job “New Item > Free style project”
3) Source Code Management > provide ACE Project Git Repository.

4) BUILD Section > Add build step > Execute Shell.

==========
echo “Creating bar file”

ACE_HOME=/opt/ibm/ace-11.0.0.9
APP_NAME=SB_REST2MQ_API_SIMPLE
GROUP_ID=com.ibm.esb

echo “Creating bar file”
$ACE_HOME/tools/mqsicreatebar -data $WORKSPACE -b barfiles/${APP_NAME}.bar -cleanBuild -a ${APP_NAME} -deployAsSource -trace -v createbartrace.txt

echo “Setup mqsi command environment – mqsiprofile”
. $ACE_HOME/server/bin/mqsiprofile

# Override bar files.
mqsiapplybaroverride -b barfiles/${APP_NAME}.bar -p SB_REST2MQ_API_SIMPLE/properties/dev.properties -o barfiles/${APP_NAME}_DEV_${BUILD_NUMBER}.bar -r
mqsiapplybaroverride -b barfiles/${APP_NAME}.bar -p SB_REST2MQ_API_SIMPLE/properties/qa.properties -o barfiles/${APP_NAME}_QA_${BUILD_NUMBER}.bar -r

# Nexus Artifactory Upload
zip barfiles/${APP_NAME}_${BUILD_NUMBER}.zip barfiles/${APP_NAME}_DEV_${BUILD_NUMBER}.bar barfiles/${APP_NAME}_QA_${BUILD_NUMBER}.bar

# Upload using curl
curl -u admin:password –upload-file barfiles/${APP_NAME}_${BUILD_NUMBER}.zip \
http://localhost:8081/repository/generic/com/ibm/esb/${APP_NAME}/${BUILD_NUMBER}/${APP_NAME}.zip

# Git – tag the version
git tag -a ${BUILD_NUMBER} -m ‘Tagged by Jenkins build’
git push git@github.ibm.com:xxx/SB_REST2MQ_API_SIMPLE.git –tags

echo “… END …”
================================

Post Build Step
Add a post build step to invoke deploy to Development jenkins job.

Save Jenkins Build Job.

Build Now

Check “console output”, make sure the build job ran successfully.

When successful, you should see the zip containing bar files should be uploaded to Nexus repository as below.

Check github repo, and make sure the project is versioned with the build number.

Deploying bar file to Development

Jenkins > Credentials >
Create a secret text ID for ACE webadmin id/password. Create the webadmin ID using mqsiwebuseradmin command.
$ mqsiwebuseradmin

ACE admin security configuration with queue-based authorization and LDAP authentication step-by-step

Create ACE WebAdmin “jenkins” secret text ID in Jenkins > Credentials.

Jenkins > New Item > Free Style Job > SB_RESTAPI_SIMPLE_DEPLOY_DEV

Build > Execute Shell
=======
APP_NAME=SB_REST2MQ_API_SIMPLE

# Artifact download
curl -X GET -u admin:password “http://localhost:8081/repository/generic/com/ibm/esb/${APP_NAME}/${PARENT_BUILD_NUMBER}/${APP_NAME}.zip” -o ${APP_NAME}.zip

unzip -o ${APP_NAME}.zip
echo “DEPLOY bar file”

ACE_WEBADMIN_URL=https://aceserver.ibm.com:4414
INTEGRATION_SERVER=SAMPLE (Create the Integration Server prior to running the job).

waidpass=`echo -n jenkins:$ACEWEB_ID_JENKINS_PASS | base64`

curl -k -X POST $ACE_WEBADMIN_URL/apiv2/servers/$INTEGRATION_SERVER/deploy \
–data-binary @barfiles/${APP_NAME}_DEV_${PARENT_BUILD_NUMBER}.bar \
-H “Content-Type: application/octet-stream” \
-H “Authorization: Basic $waidpass”

# TESTING THE API
curl -X POST http://aceserver.ibm.com:7080/sb_rest2mq_api_simple/v1/createcustomer

echo “… END …”
=======

Save, “Build Now” – check “console output”.

Similarly create Jenkins jobs for QA, and PROD and deploy QA.bar, and PROD.bar files.

Project Interchange
SB_REST2MQ_API_SIMPLE.zip


#AppConnectEnterprise(ACE)
#Cloudintegration
#Jenkins
#git
#Nexus