Deploying REXX with Jenkins, Docker, & Zowe CLI

Dan Kelosky
Zowe
Published in
5 min readSep 1, 2022

--

{Core} Here we’ll look at setting up some automation within Jenkins to deploy REXX code to a mainframe environment, using The Open Mainframe Project’s Zowe Command Line Interface (CLI). Neither Jenkins nor the agents need to run on z/OS.

The end process looks something like this:

Tools

  • VS Code → code editing
  • git + GitHub (or similar) → source control
  • Jenkins → automation
  • Zowe CLI → mainframe interaction
  • Docker → Jenkins instance & container with Zowe CLI installed

For now, we’ll skip the details and explanation of these tools — those blogs already exist. If you follow along and try the process as is laid out here, you’ll learn all about them anyway as you work through the steps.

Prereqs (i.e. The Hard Part)

To proceed, you need an instance of Jenkins. If starting from scratch, you’ll probably want to obtain access to a Linux system and get Jenkins running there.

There are a lot of details to work out, but the “easiest” approach to get Jenkins running is to follow the steps here using docker.

I chose to use Windows Subsystem for Linux (WSL2) on a Windows machine (without Docker Desktop), but a VM running Linux or real Linux machine are options as well.

Before starting Jenkins I ran: sudo chown $USER /var/run/docker.sock.

Then, I started my Jenkins instance using: docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home -v $(which docker):/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock jenkins/jenkins:lts-jdk11.

This means I can run containers specified in a Jenkinsfile on the Jenkins “controller”. This isn’t recommended, but simplifies setup and can be revisited later.

After starting Jenkins, you’ll probably need to add the Docker plugins (I also installed other plugins, like Blue Ocean).

Docker Zowe CLI w/Daemon Mode

The Jenkins pipeline will run our deploy scripts in a docker container which contains an installed instance of Zowe CLI with daemon mode enabled.

The agent used in this project was copied from Timothy Johnson’s gist with the addition of bash and other customizations. It’s intended to be a minimal docker container with Zowe CLI installed and is capable of running Zowe CLI commands in daemon mode.

You’ll need to build this Dockerfile via docker build --tag zowe/daemon . You can test out the container via docker run -it --rm zowe/daemon /bin/bash:

Running the container interactively

GitHub Project Setup

In GitHub, you can “fork” (copy) this repo to your own repo. The repo contains simple REXX code that you can build and run from your work station if you follow the README.

You should generate a personal access token and save it off to into Jenkins credential manager in the next step.

Jenkins Pipeline Setup

Once you have Jenkins and a copy of the repo, you can add a new item: a “Multibranch Pipeline”.

Connect to your GitHub project and add credentials using a personal access token from your repo (snippet of mine shown here):

The credentials value shown is the credential “ID” not the credential itself — substitute for your own repo

Lastly, add mainframe credentials to Jenkins — the credential ID expected in the Jenkinsfile is zowe-automation (the pipeline uses a declarative pipeline syntax):

Example of adding a credential within Jenkins

Final result

To recap: we have a Jenkins instance setup and a pipeline which will run a Docker container with Zowe CLI in it. When we trigger the pipeline, we’ll clone our GitHub repo which contains REXX code and invoke automation to deploy the REXX code to a mainframe system.

Run the pipeline by clicking “Run”:

Invoked manually for now via the UI but this could be trigged by a “push”

View the successful status:

All steps run

Lastly, verify REXX has been uploaded:

Sign onto the target mainframe system and see REXX code deployed

See this link to learn more about triggering the pipeline via GitHub instead of invoking the “Run” manually

Summary

This is not a trivial exercise to follow for those new to the tooling mentioned here. In my case, it took me exactly 101 pipeline runs (see screenshot above) to get everything setup the way I wanted (and that was after already spending several hours setting up the prereqs).

Once complete though, you’ll have a repeatable process that can be extended to automate larger workflows using Zowe CLI.

Supplemental information for Docker, Jenkins, and Zowe CLI can be found in an awesome blog by Petr Plavjaník.

Finding out more

If you enjoyed this blog, check out more at the Zowe blogs site. Zowe will also be featured in several sessions at Open Mainframe Summit, hosted virtually or in-person in Philadelphia, PA, on September 21–22. Register here.

Or, ask a question and join the conversation on the Open Mainframe Project Slack Channel #Zowe-dev, #Zowe-user or #Zowe-onboarding. If this is your first time using the slack channel register here.

--

--

Dan Kelosky
Zowe

Likes programming/automation in mainframe (assembler, C/C++), distributed (Node.js), and web development (Firebase, Angular).