Using BMC AMI SQL Assurance as part of a pipeline


You can use  features in the following types of pipelines:

  • Scripted Pipelines
  • Declarative Pipelines using other jobs (projects)

For a sample pipeline, see Sample-pipeline-script-for-Jenkins.

 environment variables

provides the following environment variable for pipelines. You can use this variable in your pipeline script to control the flow of pipeline steps.

Variable

Description

BMC_GENERATE_JCL_ONLY

This variable has one of the following values:

  • TRUEindicates that you have selected the Generate JCL Only check box when configuring the  - Analyze Static SQL and/or  - Analyze Dynamic SQL build step(s).
  • FALSEindicates that you have not selected the Generate JCL Only check box.

BMC_STATIC_RC

This variable provides a four-digit return code for the BMC AMI SQL Assurance for Db2 - Analyze Static SQL build step (for example, 0004)

BMC_DYNAMIC_RC

This variable provides a four-digit return code for the BMC AMI SQL Assurance for Db2 - Analyze Dynamic SQL build step (for example, 0004)

BMC_EXEC_RC

This variable provides a four-digit return code for the BMC AMI DevOps Common - JCL Execution build step (for example, 0004)

Using  environment variable in your pipeline script

This topic describes:

Before you begin

  • For prerequisite plug-ins that you must install to use  features in pipelines, see Planning.
  • Before using the  environment variables in your pipeline script, you must import the following static packages into the script:
    • import static com.bmc.db2.bmcclient.BMCClientCN.bmcCN
    • import static com.bmc.db2.bmcclient.BMCClientSA.bmcSA
  • For more information, see Sample-pipeline-script-for-Jenkins.

How to retrieve and reset  environment variable value

You can use the following methods to retrieve and reset the value of the  environment variable respectively:

  • get(String arg)
  • reset(String arg)
  • getRC(String arg)

In the get, getRC, and reset methods, you can pass the  environment variable as a string argument. See the following examples:

Examples for using the get() and getRC() methods to retrieve a value of the BMC AMI SQL Assurance environment variable
  • boolean var1 = bmcSA.get("BMC_GENERATE_JCL_ONLY")
  • boolean var2 = bmcSA.getRC("BMC_STATIC_RC")
  • boolean var3 = bmcSA.getRC("BMC_DYNAMIC_RC")
  • boolean var4 = bmcCN.getRC("BMC_EXEC_RC")
Examples for using the reset() method to reset a value of the BMC AMI SQL Assurance environment variable
  • boolean var1 = bmcSA.reset("BMC_GENERATE_JCL_ONLY")
  • boolean var2 = bmcSA.reset("BMC_STATIC_RC")
  • boolean var3 = bmcSA.reset("BMC_DYNAMIC_RC")
  • boolean var4 = bmcCN.reset("BMC_EXEC_RC")

How to provide permission to use the  environment variable


To use the  environment variable in your pipeline script, you must explicitly approve the following methods and variables:

  • method com.bmc.db2.bmcclient.BMCClientCN get java.lang.String
  • method com.bmc.db2.bmcclient.BMCClientCN getRC java.lang.String
  • method com.bmc.db2.bmcclient.BMCClientCN reset java.lang.String
  • method com.bmc.db2.bmcclient.BMCClientSA get java.lang.String
  • method com.bmc.db2.bmcclient.BMCClientSA getRC java.lang.String
  • method com.bmc.db2.bmcclient.BMCClientSA reset java.lang.String
  • staticField com.bmc.db2.bmcclient.BMCClientCN bmcCN
  • staticField com.bmc.db2.bmcclient.BMCClientSA bmcSA

When you build a pipeline, it first fails and displays a message with a link to the In-process Script Approval section in Jenkins. Click the link and approve the method or variable.

Example

Scripts not permitted to use method com.bmc.db2.bmcclient.BMCClientSA get java.lang.String. The Administrators can decide whether to approve or reject this signature.

For pipeline scripts previously created using the Jenkins Pipeline Snippet Generator

To modify an existing pipeline script for the plug-in modules, we recommend that you perform the following steps:

  1.  Reuse the Pipeline Snippet Generator dialog to make your modifications.
  2.  Regenerate the Pipeline script.

    Important

    Avoid modifying the pipeline script directly.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*