Quick start to automating Db2 schema changes and validation with BMC AMI DevOps
This topic explains how to automate schema changes between IBM Db2 for z/OS environments and to validate schema requirements by using BMC AMI DevOps for Db2. This process uses a continuous integration/continuous delivery (CI/CD) project or pipeline integrated with schema change management via tools such as Jenkins, Azure DevOps, GitHub Actions, and GitLab CI/CD.
Before you begin
- Make sure that you have working z/OSMF and Db2 environments on z/OS.
- Make sure that you have BMC AMI Change Manager for Db2 working for your Db2 environment.
- Make sure that you have credentials and network access to your Db2 subsystems.
- If you're using Jenkins, install and configure it on a host that can access your z/OSMF and Db2 environment on the mainframe.
- If you're using the Universal Connector, make sure that a container runtime is installed and network connectivity is set up.
- Download the BMC AMI DevOps for Db2 zip file package from the BMC Support Electronic Product Distribution (EPD) site.
- Understand your organization’s schema standards and change management policies.
1. To install, configure, and verify
Choose the option that best fits your environment:
- Jenkins plug-in: Select this option if you already use Jenkins for CI/CD pipelines.
- Universal Connector container: Select this option if you prefer a containerized setup or use a CI/CD tool other than Jenkins.
To download and install
To verify installation
|
To download and install
|
To verify installation
|
2. To prepare for BMC AMI DevOps configuration
Create partitioned data sets (PDSs) for the following items on the mainframe (if they don't already exist) with LRECL=80 and unique names.
- CDL file
- DDL file
- Execution JCL
- Analysis impact report
- Worklist
Create rollback PDSs with unique names on the mainframe for the following items:
- CDL file
- Execution JCL
- Analysis impact report
- Worklist
Customize the plug-in variables file.
In the plug-in variables file provided in the downloaded package, AMI_DevOps.properties, customize the variable values. Depending on your CI/CD tool, select either: Using BMC AMI DevOps in Jenkins or Using BMC AMI DevOps with Universal Connector.Make sure that the plug-in variables file is available in the environment in which you run the deployment.
3. To create your first project or pipeline
After the setup, you can test a simple schema change through a CI/CD project or pipeline.
Step 1: To prepare a sample DDL
Create a small SQL file. For example:
Save it in a Git repository that your pipeline can access.
Step 2: To define a project or a pipeline Job
Define a project or pipeline in Jenkins:
Create a new project or pipeline.
Add the BMC AMI DevOps Common - Authentication step to connect via z/OSMF to the mainframe and configure.
Add the BMC AMI DevOps Common - File Transmission step and configure to upload the DDL file to the mainframe.
Add the BMC AMI DevOps Schema Mgmt for Db2 - Schema Change Migration step to perform the following steps:
- Run a compare of the Db2 catalog with the sample DDL file.
- Configure the compare step to point to your test Db2 subsystem
- Specify the comparison type of Local Catalog to DDL File with DDL File as scope and the applicable inputs needed for the compare.
Add the BMC AMI DevOps Schema Mgmt for Db2 - Output Transmission step to download the compare artifacts to the Jenkins workspace.
Add the BMC AMI DevOps Common – JCL Execution step to run the JCL from the Schema Change Migration step and run the JCL from the Mainframe PDS member. For this test, select the Disable Build step so that it won’t immediately run the changes.
Add the BMC AMI DevOps Common – Clean Up step.
Save the project or pipeline.
Define a pipeline Job in your Universal Connector CI/CD tool:
Create a new config yaml file in your CI/CD tool repository.
Use the sample config yaml file, Config Schema Migration_ALL_Steps.yml, found in the downloaded zip file from the BMC EPD site, copy the following application steps and give the applicable configuration details:
- Add the authentication step to connect via z/OSMF to the mainframe.
- Add the fileUpload step to upload the DDL file to the mainframe.
- Add the localCatToDDL step to run a compare of the Db2 catalog with the sample DDL file.
- Add the outputTransmission step to download the compare artifacts to the tool’s workspace.
- Save the config yaml file.
Use the sample pipeline or workflow yaml file, Pipeline/Workflow_Schema Migration_Sample.yml, found in the downloaded zip file from the BMC EPD site, copy the file and update the following details:
- Define your trigger method, container image, variables, agent as applicable to your CI/CD tool.
- Define the initialization commands to find and replace variables defined in the config and pipeline files.
- Add each step to run from the config yaml file.
- Save the pipeline yaml file.
Step 3: To run and review
Trigger the project or pipeline manually.
Watch the console or job log for progress.
- After the job finishes running, verify that the results are acceptable in the console, job log, and the compare artifacts.
4. To configure and apply schema standards
Schema standards help ensure that database changes follow your organization’s rules.
Step 1: To create schema rules
Using the Product Tools perspective in BMC AMI Command Center for Db2, follow these steps:
- Create schema standards rule set.
- Create schema rules required in your organization:
- Rule name
- Rule explanation
- Object type
- Rule expression
- (optional) When condition
We provide a sample rule set with rules for trial purposes.
Step 2: To create schema standards project or pipeline
Depending on whether your using Jenkins or UC, create a new Jenkins project or pipeline or UC config yaml file.
Add the authentication step
Add the applicable tool’s Schema Standards step: BMC AMI DevOps Schema Mgmt for Db2 - Schema Standards or schemaStandards (stepName: schema_standards_ddl).
- Configure the step by using the Schema Standards rule set name, source of schema: DDL, and the DDL PDS data set and member.
- Save the project or config yaml file.
If you're using UC, create a new UC pipeline yaml file.
- Configure with the authentication and schemaStandards application step.
- Save the pipeline yaml file.
Step 3: To run and review
Trigger the project or pipeline manually.
Watch the console or job log for progress.
After the job completes, verify the console and job log results.
Review the Schema standards violation report in the job output or via Schema Standards Violation Details view in BMC AMI Command Center.
If any violations appear, fix the issue, and rerun the Schema Standards job.
5. To promote changes across environments
After your test project or pipeline succeeds, update your Jenkins project or pipeline or UC config file, and pipeline files:
- Update to the target QA, staging, or production Db2 subsystems.
- Add the Schema standards step.
- Enable the JCL Execution step to make the schema changes.
Always review logs and test results before promoting to the next environment.
6. To verify and troubleshoot
After deployment:
- Check the Db2 catalog to confirm that the change was applied successfully.
- Review the logs generated by Jenkins or the CI/CD tool for errors or warnings.
- If you encounter problems:
- Verify network access to Db2.
- Verify that your credentials have the correct privileges.
- Review your schema standards file for incorrect rules.
For more information, see Troubleshooting.
Tips and best practices
- Start with small, simple changes to test your setup.
- Keep configuration files in version control.
- Enable detailed logging when troubleshooting.
- Run schema validation before every deployment.
- Back up critical data before promoting major changes.