This sample groovy script lets you embed the IBM Developer for z/OS (IDz also formerly Rational Developer for System z or RDz) Code Review batch application, also known as IDz Software Analyzer, into your CI/CD pipeline. For the host, this requires that the IDz code analysis tool (AKGCR) is installed via FMID HAKGxxx. Please see the documentation at https://www.ibm.com/docs/en/developer-for-zos/16.0?topic=review-code-application-zos
This sample groovy RunCodeReview.groovy
script
- extracts information about the processed source code (Record Type TYPE_COPY_TO_PDS) from the DBB BuildReport.json
- assembles and runs a JCL to invoke IDz Code Review in Batch.
- Read command line parameters and the mandatory
codereview.properties
file for externalizing parameters - either via Command Line Interface (CLI) parameter or from its default location. - Read DBB's BuildReport.json from the pipeline work directory
- Parse and extract processed source code info from COPY_TO_PDS records from the build report
- Extract the SYSLIB information
- Generates an JCLExec for invoking the IDZ Code Review application
- Stores the IDz Code Review reports
CodeReviewCSV.csv
,CodeReviewJUNIT.xml
as well as the JCL spool in the DBB build output directory (workDir).
The script will exit with the following return codes:
- 0 - No problem encountered
- 1 - Maximum acceptable return code of Code Review exceeded
- 2 - Wrong configuration (Missing Property Group file, while no SYSLIB concatenation was found or defined).
Invoke RunCodeReview.groovy passing the work directory, which stores the BuildReport.json. The property file codereview.properties
is retrieved from the default location, which is the location of the RunCodeReview.groovy
$DBB_HOME/bin/groovyz RunCodeReview.groovy --workDir /var/dbb/buildworkspace/zAppBuild/work
Invoke RunCodeReview passing the work directory, which stores the BuildReport.json. The property file codereview.properties
is defined via the commandline argument --properties
$DBB_HOME/bin/groovyz RunCodeReview.groovy --workDir /var/dbb/buildworkspace/zAppBuild/work --properties /var/dbb/integrations/codereview.properties
usage: RunCodeReview.groovy --workDir <path-to-dbb-buildreport> [options]
options:
-w,--workDir <dir> Absolute path to the DBB build output directory
-cr,--crRulesFile (Optional) Absolute path of the rules file. If not provided, will look for it in the codereview.properties file
-ccr, --ccrRulesFile (Optional) Absolute path of the custom rules file. If not provided, will look for it in the codereview.properties file
-l,--logEncoding (Optional) Defines the Encoding for output files (JCL spool, reports), default UTF-8
-props,--properties (Optional) Absolute path to the codereview.properties file
-p,--preview (Optional) Preview JCL, do not submit it
-rc, --maxRC (Optional) Maximum acceptable return code. If not provided, will look for it in the codereview.properties file
-h,--help (Optional) Prints this message
-cp,--codepage <arg> (Optional) Code Page of the source members to be processed. By default, IBM-037 is used by Code Review if none is specified.
If not provided, will look for it in the codereview.properties file.
-pgFile,--propertyGroupFile Absolute path of the Property Group file. This file has to be a Local Property Group file.
Optional if SYSLIB concatenation is found by the script, otherwise required.
requires:
codeview.properties file - externalizes the JCL jobcard, RuleFile and Mappings, maximum acceptable return code, codepage and Property Group file.
If --properties is not provided via cli, the script looks for it at the location of the script itself
Please review the descriptions provided for the variables within the codereview.properties file and adjust them according to your environment.