Zowe CLI: Tips & Tricks

Michael Bauer
Modern Mainframe
Published in
5 min readJul 23, 2020

Wherever you may be in your Zowe CLI journey, this blog offers valuable tips and tricks to help you unlock the value even faster. If you’re unfamiliar with Zowe or you’re just getting started, these tips will help you. If you consider yourself an experienced user, you may very well learn something new so keep reading!

Tip #1: Web Help!

If you are running the Zowe CLI in an environment from which a Chrome or Firefox web browser can be launched, you can take advantage of Zowe CLI web help. By appending --help-web or--hw for short to any CLI command, you will launch in-context help in your default browser. The generated web-help is customized to your installation based on the plug-ins you have installed. However, if you do not have the Zowe CLI installed ...yet 😎, you can check out Zowe interactive web help here.

Zowe CLI Web Help

Tip #2: Zowe CLI Prompting

By specifying prompt* as a CLI option value, you can request to be prompted for an option value. The value will not be shown when entered allowing you to enter sensitive information without it being displayed on the screen.

Zowe CLI Prompting

Tip #3: Easily Abstract Commands into NPM Scripts

The true power of the CLI lies in abstracting commands into scripts. Since Node is a prerequisite for the CLI, let’s build out some simple automation using Node. In the GIF below, we initialize a Node project, add a single task to list data sets, and then we invoke this automation via the npm CLI and NPM Scripts tree in VS Code.

This automation is not limited to single Zowe CLI commands. Multiple commands or scripts could be invoked from a single task.

Others in the community, like mrBeeTech, have also provided some great content.

Tip #4: Command Line Precedence

Zowe CLI has a command line order of precedence. Options can be specified on the command line, in environment variables, or in profiles. Command line options override environment variables which override values stored in profiles. This is demonstrated in the following GIF.

Zowe Command Line Precedence

You can learn more about Zowe command line order of precedence here. This enables you to leverage other means to manage secret values. For example, you may want to store your secrets in Jenkins. An example Jenkinsfile where Jenkins secrets are leveraged to influence Zowe CLI commands can be viewed here.

Tip #5: Project Profiles

If you are an experienced CLI user, you probably have some profiles created. Profiles are configuration files used for storing information that would otherwise need to be repeatedly entered to run various commands. Perhaps the number of profiles you use and manage has grown over time and you have to constantly change your default profiles depending on what project you are working on. A handy script can help you easily switch profiles when working on different projects and help others onboard more easily.

For any given project, I usually have an init script in my package.json that sets up my local CLI environment for working with the relevant services. I construct a config.json file to source all of the service details for my particular project. You can also add other config options there if needed. When invoked, the script requests information that I do not want to store in source control for my project, like username & password, and then runs the needed Zowe CLI commands to set up my profiles. Onboarding contributors becomes as easy as git clone, npm install,npm run init, enter username & password, and they are ready to develop 😃. Interested? Check out a sample project here!

Tip #6: CA Endevor for Zowe CLI: Retrieve Multiple Elements

If you are a CA Endevor user, you can leverage the CA Endevor Plug-in for Zowe CLI to retrieve elements from your sandbox environment. In fact, you can retrieve multiple elements with a single command like zowe endevor retrieve element "*" --to-dir . --stage-number 1 --typ "*" --nsign

Tip #7: z/OS Extended Files for Zowe CLI: Download Multiple Data Sets

If you have CA Brightside, you have access to the z/OS Extended Files Plug-in for Zowe CLI. This extension provides some advanced features for working with data sets including the ability to easily download custom groups of data sets using a single command. For example, the following command will download all non-PUBLIC JCL data sets under the CUST002 high level qualifier:
zowe files-e download pattern "CUST002.**.JCL" --exclude-patterns "CUST002.PUBLIC.*" -e .jcl

Tip #8: z/OS Extended Jobs for Zowe CLI: Delete Jobs with OUTPUT Status

If you have CA Brightside, you also have access to the z/OS Extended Jobs Plug-in for Zowe CLI. This extension provides some advanced features for working with jobs including the ability to easily delete your jobs with OUTPUT status using the following command:
zowe jobs-e delete old-jobs

I hope these tips help you in your use of the Zowe CLI. Happy coding 😄

--

--

Michael Bauer
Modern Mainframe

Engineering Manager at Broadcom; Main areas of expertise include AIOps, DevOps, Endevor, NetMaster, and Zowe (zowe.org); 410 Sprint Car Driver