GitLab CI (Continuous Integration) is a service included in GitLab. It brings the DevOps best practices into the application development phase. When developers deliver code modifications, it triggers a pipeline that automatically builds, tests, and deploys the application into the target environment.
This tutorial focuses on how you can use GitLab CI to build a Continuous Integration / Continuous Deployment (CI/CD) pipeline. In GitLab, you can define a project that combines a Git repository with CI/CD pipeline features.
In this tutorial, you will learn how to configure GitLab CI for a CI/CD pipeline that includes builds with IBM Dependency Based Build (DBB), packaging and deploy phases with IBM UrbanCode Deploy (UCD), automated unit testing with the zUnit feature of IBM Developer for z/OS (IDz), and code coverage and code review with IDz.
This tutorial assumes that you have already configured UCD and therefore does not detail this step.
The sample application for this tutorial is GenApp, the IBM standard CICS application.
After the configuration steps, this tutorial shows how to quickly test the configuration by starting a GitLab CI build that runs a DBB build. This build creates a version with the client UCD, uploads the binary files to JFrog Artifactory, and deploys the application through UCD, using the binary files in Artifactory.
Note: This tutorial uses only one pipeline for all the steps (build, test, code coverage, IDz code review, package, deploy). However, in a real environment this should be split into several pipelines depending on the step (development, staging, production, and so on).
Prerequisites
You need to make sure that the following prerequisites are fulfilled:
An account on the public GitLab server or on a local GitLab server. This tutorial is based on version 13.9.0 of the public GitLab server (https://gitlab.com).
IBM DBB toolkit (version 1.0.9.ifix1 or later). See Installing and configuring DBB. It is highly recommended to install the latest PTF for the removal of the blank character in the first column of IDz code review reports.
Note: You must have configured UrbanCode Deploy, as explained in Part 1. Configure UrbanCode Deploy of the tutorial “Build a pipeline with Jenkins, Dependency Based Build, and UrbanCode Deploy."
The GenApp application. It must be installed in your CICS environment and CICS management client interface (CMCI) must be configured. You can download GenApp from the IBM Support website.
(Optional) For zUnit, xsltproc is used on the distributed system. This binary file is required to perform Extensible Stylesheet Language Transformation (XSLT) of the zUnit test result to a format that the GitLab CI can understand. Most of the Linux distributed systems provide this binary file.
Estimated time
It should take you about 60 minutes to complete the steps in this tutorial. However, this estimated time does not include the time required to configure UCD (as mentioned in the Prerequisites section).
Steps
Here are the steps required to build a CI/CD pipeline using GitLab CI.
A group in GitLab is a collection of projects. This group will contain the GitLab projects that will be created by importing the existing DBB GitHub repositories.
In the GitLab menu bar, click New > New Group.
In the Create Group wizard that opens, enter the name of the group and click Create group.
Step 2. Create the runners in the GitLab group
Runners are the agents that interact with GitLab CI on the operating systems.
1. Install the GitLab runner
You must install the GitLab runner version 13.8.0 or later according to your operating system. For this tutorial, it is installed on a Linux system, but it could also be installed on Microsoft Windows, Linux for IBM Z, or IBM z/OS Container Extensions (IBM zCX).
After you’ve installed the GitLab runner, you must register your own runners to run the CI/CD jobs that come from GitLab and optionally send the result back to the GitLab server. So, you must set up the communication between the GitLab server and the system to which the runner is connected.
2. Configure a runner for z/OS
In a z/OS environment, a limitation is that it is necessary to use a runner that uses a Secure Shell (SSH) executor. Be sure to apply the prerequisites as detailed in the tutorial “Integrate IBM z/OS platform into continuous integration pipelines with GitLab.”
In the system where you installed the GitLab runner, you must register a runner with the gitlab-runner register command line by specifying the following elements:
Specify the GitLab instance URL: https://gitlab.com. This is the URL of the GitLab server.
Specify the registration token that is associated with the group. To get this token, go back to the group you created in GitLab and click Settings > CI / CD.
Paste the value of the registration token when prompted.
Enter a description for the runner: SSH executor on the targeted z/OS.
Enter a tag for the runner: zos-ssh. So, when you create a pipeline you will be able to specify that a job will run on this runner.
Enter a type of executor: ssh. The executor determines the environment where each job runs. To target a z/OS environment, the only option is to use SSH.
Enter the SSH server address: your z/OS hostname. This is the IP address of the z/OS server that you will log into with the SSH protocol.
Enter the SSH server port. This is generally 22 but it can vary according to your environment.
Enter the SSH user who will connect through SSH. Reminder: This user must have Bash as default shell.
Enter the SSH password. If you do not want to enter the password, you can leave it blank and use an SSH private key instead.
Now that the runner for z/OS is successfully configured, you can configure another runner for Linux if you want to push your DBB build log and zUnit back to the GitLab server.
3. (Optional) Configure a runner for Linux
If you want to push the build log and zUnit test back to the GitLab server, you’ll need to configure this second runner because there is a limitation for an SSH executor on z/OS. You also need to set the GITLAB_REPORT_UPLOAD variable to true in the GitLab pipeline (as mentioned later in this tutorial). The build log files and the zUnit test results from the CI/CD pipeline cannot be published on the GitLab server with the z/OS SSH executor. So, the only way to publish the logs and the test results is to start a job that runs on a distributed system through a shell-type runner.
In the system where you installed the GitLab runner, you must register a runner with the gitlab-runner register command line by specifying the following elements:
Enter the registration token that is associated with the group. This is the same token as for the first runner.
Enter a description for the runner: Shell executor on runner OS.
Enter a tag for the runner: dist-shell.
Enter a type of executor: shell.
The runner for Linux is now successfully configured.
4. Display the runners in the GitLab group
If you refresh the page of the CI/CD group settings, you can see that the two runners you just created are available and are ready to be used by your group.
You must create projects in the GitLab group to store the scripts that build the GenApp application. You need not create these projects from scratch. Instead, you can simply import the corresponding DBB GitHub public repositories.
You need to import the following two GitHub repositories:
dbb, which contains the scripts that are necessary to run the DBB builds.
zAppBuild, which contains the Groovy scripts that are necessary to build a COBOL application in z/OS.
In this code, the Dependencies stage means that you will be able to clone the DBB repository when needed. The zos-ssh tag indicates the runner to be used. The only variable $CI_PIPELINE_SOURCE == 'pipeline' means that this pipeline can be started only from another pipeline. So, for example, it will not start if you modify a file in this project.
Click Commit changes.
2. Import the zAppBuild project
Now, you must import the other project,zAppBuild, which contains the Groovy scripts to build a z/OS application.
2.1. Create the zAppBuild GitLab project
The explanations given to create the dbb project also apply here, except for the following values on the Import project page:
The next step is to add environment variables to the GitLab group to manage the passwords needed for your pipeline.
Step 4. Configure environment variables in the GitLab group
You must configure environment variables that will be used for the GenApp application. These variables correspond to passwords that will be required to log into Artifactory and UCD. This way, the passwords will be hidden.
So, navigate to the CI/CD Settings of the GitLab group and click Add Variable in the Variables section.
You need to create the variable that corresponds to the Artifactory password. Enter GROUP_ARTI_PASSWORD in the Key field and the password in the Value field. In the Flags section, clear the Protect variable checkbox and select the Mask variable checkbox. Then, click Add variable.
Next, you need to create the variable that corresponds to the UrbanCode Deploy password. Enter GROUP_UCD_PASSWORD in the Key field and the password in the Value field. In the Flags section, clear the Protect variable checkbox and select the Mask variable checkbox. Then, click Add variable.
You can see that the two variables are now configured in the GitLab group.
Next, you must import the GitHub repository that contains examples of CI/CD pipeline scripts integrated with IBM DBB.
Step 5. Import the dbb-pipeline GitHub repository
This GitHub repository contains examples of CI/CD pipeline integrated with DBB. You must import it and create a project in your GitLab group.
The explanations given to create the dbb project also apply here (see Create_the_dbb_GitLab_project), except for the following values on the Import project page:
In the Git repository URL field, copy and paste the URL of the public IBM DBB GitHub repository that contains the pipeline scripts: https://github.com/ibm/dbb-pipeline.
In the Project name field, enter dbb-pipeline.
In the Project URL field, open the drop-down list and select the GitLab group that you have created.
Then, click Create project.
GitLab imports the dbb-pipeline repository from GitHub and creates the dbb-pipeline project in your GitLab group, as you can see in the following screen capture.
Before you set up the CI/CD pipeline for the dbb-pipeline project, which will build the GenApp application, you must add the GenApp source files and modify a properties file.
1. Add the application source file
At the time this tutorial is being written, the source code of GenApp is available only as IBM MVS content through the IBM Support. From IBM Support, you need to extract the source code on MVS and add it back to the dbb-pipeline project.
Add the GenApp source files to the cics-genapp folder of your dbb-pipeline repository with the following structure:
- cics-genapp
- base
- src
- BMS
- Duplicate the contents ofthe PDS 'HQL'.BMS
extracted onMVSfromSOURCE.XMIT
- COBOL
- Duplicate the contents ofthe PDS 'HQL'.COBOL
extracted onMVSfromSOURCE.XMIT
- COPY
- Duplicate the contents ofthe PDS 'HQL'.COPY
extracted onMVSfromSOURCE.XMIT
Show more
Note: The transferred files must have their corresponding extensions in the Git repository. The extension is .cbl for the COBOL files, .bms for the BMS files, and .cpy for the COPY files.
2. Modify the datasets.properties file
You must adapt this file to your z/OS environment.
In your dbb-pipeline repository, under the cics-genapp folder, open the application-conf subfolder. Then, open the datasets.properties file.
Change the default properties to adapt them to your environment.
Now you are ready to set up and run the CI/CD pipeline that integrates GitLab CI.
Step 7. Create the CI/CD pipeline
With the IDE of your choice, clone the dbb-pipeline project you created before in GitLab, locate and edit the .gilab-ci.yml.sample file, which contains the CI/CD pipeline. Rename this file as .gilab-ci.yml and adapt the pipeline global variables to your environments.
By default, the zUnit, Code Coverage, Code Review, and GitLab reporting features are disabled. You can enable them if you have configured the related optional tasks mentioned in this tutorial by setting the following variables to true:
You can click buildReport.html to see the result of the DBB build, or the .log files to see the result of the COBOL programs compilation. If you click the .pdf file, you can open the PDF that contains the Code Review report. A sample is shown in the following screen capture:
This tutorial has helped you understand and set up GitLab CI facilities to integrate z/OS platforms into a unique solution. You can now build a CI/CD pipeline that’s orchestrated with GitLab CI for a CICS application with Dependency Based Build (DBB) and UrbanCode Deploy (UCD). You can also extend your GitLab CI pipeline with z/OS actions to include unit testing, code review, and code coverage.
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review your cookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.