Sample pipeline scripts for Azure DevOps
The sample pipelines are located in SQL Assurance Sample Folder in the Azure DevOps directory, which is the directory to which the BMC-AMI-SQL-Assurance-Version-13.1.00-for-Db2-UC.zip file is downloaded and extracted. For example: C:\Users\userName\Downloads\BMC-AMI-SQL-Assurance-Version-13.1.00-for-Db2-UC\BMC AMI SQL Assurance Version 13.1.00 for Db2 - UC\Azure DevOps\SQL Assurance Sample Folder
Sample pipeline script for SQL Assurance Dynamic SQL
The following figure represents a sample pipeline script for SQL Assurance Dynamic SQL:
###
### Pipeline_SQL_Assurance_Dynamic_SQL_Sample.yml (for Azure DevOps)
###
# The sample pipeline performs Authentication + Dynamic SQL steps using application defined command step.
# The sample pipeline script is defined to use various items like below:
# a) References to variables added in Variable group.
# b) Use of Linux based sed command to replace input as variable name by variable definition from pipeline.
# c) Use of configuration file (Config_SQL_Assurance_Dynamic_SQL.yml), that resides in directory (non-root folder).
# Example of properties of authentication step is taken from config file "Config_SQL_Assurance_Dynamic_SQL.yml", that is
# maintained inside folders "Azure/SAMPLE/MAA/configFiles":
# step authentication Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
# d) Azure DevOps based condition command or bash script based IF... ELSE...FI is used.
###
trigger:
- none #manual trigger of the pipeline
resources:
containers:
- container: my_container
image:attach:xwiki:Mainframe.Data-for-Db2.BMC-AMI-SQL-Assurance-for-Db2.COB13100.Command-and-syntax-reference.Universal-Connector-samples-in-BMC-AMI-SQL-Assurance.Sample-pipeline-scripts-for-Azure-DevOps.WebHome@filename <Image location>/sqlassuranceuc:13.01.00.0001-GA
options: -u root #run the container as root user
variables:
- group: AA_SAMPLE #name of the Variable group
pool:
name: <name of the agent pool> # name of the agent pool
stages:
- stage: 'Analyze_Dynamic_SQL'
displayName: 'Analyze Dynamic SQL'
jobs:
- job: 'Dynamic_SQL'
displayName: 'Dynamic SQL Job'
container: my_container
steps:
# For certBased Authentication, uncomment the following task to download the client certificate
# stored under Azure Pipelines --> Library --> Secure files
# - task: DownloadSecureFile@1
# name: clientCertificate
# displayName: 'Download p12 client certificate'
# inputs:
# secureFile: '<clientCertificateName>.p12'
# Perform various initialization functions using Linux based command sed
- script: |
echo "Replace variables defined in Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml file"
# Linux command sed is used to replace the config file variables with variables defined in Variable group
sed -i "s/USER_ID_AUTH/$(user_id)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
sed -i "s/USER_PASS_AUTH/$(user_pass)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
# For certBased Authentication, uncomment the following 2 sed commands
# sed -i "s|CERT_PATH_AUTH|$(clientCertificate.secureFilePath)|" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
# sed -i "s/CERT_PASS_AUTH/$(cert_pass)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
# Use Azure DevOps environment variables to fetch pipeline name, run number, run by and run mode of the executing pipeline
sed -i "s/PIPELINENAME_VALUE/$(Build.DefinitionName)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
sed -i "s/RUNNUMBER_VALUE/$(Build.BuildNumber)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
sed -i "s/RUNBY_VALUE/$(Build.RequestedFor)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
sed -i "s/RUNMODE_VALUE/$(Build.Reason)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
echo "- Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml file is updated -"
displayName: 'Initialization'
# Execute application step - authentication
- script: |
step authentication Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
displayName: 'Authentication'
# Execute application step - analyzeDynamicSql (dynamic_sql)
- script: |
step dynamic_sql Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
displayName: 'SQL Assurance - Analyze Dynamic SQL'
# Fetch the return code from output file output_analyze_dynamic_sql.properties
# and set in output variable as environment variable to use in subsequent steps
- script: |
source output_analyze_dynamic_sql.properties #read and fetch the return code from output file
echo "##vso[task.setvariable variable=retCode]$dynamicSqlRC" #set the return code in output var
condition: succeededOrFailed()
displayName: 'Return Code-Dynamic SQL'##
###
# Execute dummy step - It could be any customized subsequent step based on the requirement
# Method-1: Using Azure DevOps based condition keyword - Run step only if condition is satisfied.
###
- script: |
step <dummy step name> Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
condition: and(succeededOrFailed(), le(variables['retCode'], '0004'))
displayName: 'Run Dummy step'
###
# Execute dummy step - It could be any customized subsequent step based on the requirement
# Method-2: Using bash script based IF...ELSE---FI keyword- Run step only if condition is satisfied.
--##--#
# - script: |
# if [ "$(retCode)" -le "0004" ]; then
# step <dummy step name> Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
# else
# echo "Condition is not satisfied, hence skip the run"
# fi
# displayName: 'Run Dummy step'--
### Pipeline_SQL_Assurance_Dynamic_SQL_Sample.yml (for Azure DevOps)
###
# The sample pipeline performs Authentication + Dynamic SQL steps using application defined command step.
# The sample pipeline script is defined to use various items like below:
# a) References to variables added in Variable group.
# b) Use of Linux based sed command to replace input as variable name by variable definition from pipeline.
# c) Use of configuration file (Config_SQL_Assurance_Dynamic_SQL.yml), that resides in directory (non-root folder).
# Example of properties of authentication step is taken from config file "Config_SQL_Assurance_Dynamic_SQL.yml", that is
# maintained inside folders "Azure/SAMPLE/MAA/configFiles":
# step authentication Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
# d) Azure DevOps based condition command or bash script based IF... ELSE...FI is used.
###
trigger:
- none #manual trigger of the pipeline
resources:
containers:
- container: my_container
image:attach:xwiki:Mainframe.Data-for-Db2.BMC-AMI-SQL-Assurance-for-Db2.COB13100.Command-and-syntax-reference.Universal-Connector-samples-in-BMC-AMI-SQL-Assurance.Sample-pipeline-scripts-for-Azure-DevOps.WebHome@filename <Image location>/sqlassuranceuc:13.01.00.0001-GA
options: -u root #run the container as root user
variables:
- group: AA_SAMPLE #name of the Variable group
pool:
name: <name of the agent pool> # name of the agent pool
stages:
- stage: 'Analyze_Dynamic_SQL'
displayName: 'Analyze Dynamic SQL'
jobs:
- job: 'Dynamic_SQL'
displayName: 'Dynamic SQL Job'
container: my_container
steps:
# For certBased Authentication, uncomment the following task to download the client certificate
# stored under Azure Pipelines --> Library --> Secure files
# - task: DownloadSecureFile@1
# name: clientCertificate
# displayName: 'Download p12 client certificate'
# inputs:
# secureFile: '<clientCertificateName>.p12'
# Perform various initialization functions using Linux based command sed
- script: |
echo "Replace variables defined in Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml file"
# Linux command sed is used to replace the config file variables with variables defined in Variable group
sed -i "s/USER_ID_AUTH/$(user_id)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
sed -i "s/USER_PASS_AUTH/$(user_pass)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
# For certBased Authentication, uncomment the following 2 sed commands
# sed -i "s|CERT_PATH_AUTH|$(clientCertificate.secureFilePath)|" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
# sed -i "s/CERT_PASS_AUTH/$(cert_pass)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
# Use Azure DevOps environment variables to fetch pipeline name, run number, run by and run mode of the executing pipeline
sed -i "s/PIPELINENAME_VALUE/$(Build.DefinitionName)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
sed -i "s/RUNNUMBER_VALUE/$(Build.BuildNumber)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
sed -i "s/RUNBY_VALUE/$(Build.RequestedFor)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
sed -i "s/RUNMODE_VALUE/$(Build.Reason)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
echo "- Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml file is updated -"
displayName: 'Initialization'
# Execute application step - authentication
- script: |
step authentication Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
displayName: 'Authentication'
# Execute application step - analyzeDynamicSql (dynamic_sql)
- script: |
step dynamic_sql Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
displayName: 'SQL Assurance - Analyze Dynamic SQL'
# Fetch the return code from output file output_analyze_dynamic_sql.properties
# and set in output variable as environment variable to use in subsequent steps
- script: |
source output_analyze_dynamic_sql.properties #read and fetch the return code from output file
echo "##vso[task.setvariable variable=retCode]$dynamicSqlRC" #set the return code in output var
condition: succeededOrFailed()
displayName: 'Return Code-Dynamic SQL'##
###
# Execute dummy step - It could be any customized subsequent step based on the requirement
# Method-1: Using Azure DevOps based condition keyword - Run step only if condition is satisfied.
###
- script: |
step <dummy step name> Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
condition: and(succeededOrFailed(), le(variables['retCode'], '0004'))
displayName: 'Run Dummy step'
###
# Execute dummy step - It could be any customized subsequent step based on the requirement
# Method-2: Using bash script based IF...ELSE---FI keyword- Run step only if condition is satisfied.
--##--#
# - script: |
# if [ "$(retCode)" -le "0004" ]; then
# step <dummy step name> Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
# else
# echo "Condition is not satisfied, hence skip the run"
# fi
# displayName: 'Run Dummy step'--
Sample pipeline script for SQL Assurance Static and Dynamic SQL
The following figure represents a sample pipeline script for SQL Assurance Static and Dynamic SQL:
###
### Pipeline_SQL_Assurance_Static_Dynamic_SQL_Sample.yml (for Azure DevOps)
###
# The sample pipeline performs Authentication + Static SQL (Package) + Dynamic SQL steps using application defined command step.
# The purpose of the pipeline is to extract the return code from the respective output file. Once extracted, it can be used in the
# pipeline to decide the execution of the subsequent steps.
# The sample pipeline script is defined to use various items like below:
# a) References to variables added in Variable group.
# b) Use of Linux based sed command to replace input as variable name by variable definition from pipeline.
# c) Use of configuration files (Config_SQL_Assurance_Static_SQL.yml & Config_SQL_Assurance_Dynamic_SQL.yml), that reside in directory (non-root folder).
# Example of properties of authentication step is taken from config file "Config_SQL_Assurance_Static_SQL.yml", that is
# maintained inside folders "Azure/SAMPLE/MAA/configFiles":
# step authentication Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
###
trigger:
- none #manual trigger of the pipeline
resources:
containers:
- container: my_container
image:attach:xwiki:Mainframe.Data-for-Db2.BMC-AMI-SQL-Assurance-for-Db2.COB13100.Command-and-syntax-reference.Universal-Connector-samples-in-BMC-AMI-SQL-Assurance.Sample-pipeline-scripts-for-Azure-DevOps.WebHome@filename <Image location>/sqlassuranceuc:13.01.00.0001-GA
options: -u root #run the container as root user
variables:
- group: AA_SAMPLE #name of the Variable group
pool:
name: <name of the agent pool> # name of the agent pool
stages:
- stage: 'Analyze_SQL_Statements'
displayName: 'Analyze SQL Statements'
jobs:
- job: 'Static_Dynamic_SQL'
displayName: 'Static and Dynamic SQL Job'
container: my_container
steps:
# For certBased Authentication, uncomment the following task to download the client certificate
# stored under Azure Pipelines --> Library --> Secure files
# - task: DownloadSecureFile@1
# name: clientCertificate
# displayName: 'Download p12 client certificate'
# inputs:
# secureFile: '<clientCertificateName>.p12'
# Perform various initialization functions using Linux based command sed
- script: |
echo "Replace variables defined in Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml file"
# Linux command sed is used to replace the config file variables with variables defined in Variable group
sed -i "s/USER_ID_AUTH/$(user_id)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
sed -i "s/USER_PASS_AUTH/$(user_pass)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
# For certBased Authentication, uncomment the following 2 sed commands
# sed -i "s|CERT_PATH_AUTH|$(clientCertificate.secureFilePath)|" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
# sed -i "s/CERT_PASS_AUTH/$(cert_pass)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
# Use Azure DevOps environment variables to fetch pipeline name, run number, run by and run mode of the executing pipeline
sed -i "s/PIPELINENAME_VALUE/$(Build.DefinitionName)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNNUMBER_VALUE/$(Build.BuildNumber)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNBY_VALUE/$(Build.RequestedFor)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNMODE_VALUE/$(Build.Reason)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
echo "- Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml file is updated -"
displayName: 'Initialization'
# Execute application step - authentication
- script: |
step authentication Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
displayName: 'Authentication'
# Execute application step - analyzeStaticSql (static_sql_package)
- script: |
step static_sql_package Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
displayName: 'SQL Assurance - Analyze Static SQL'
# Fetch the return code from output file output_analyze_static_sql.properties
# and set in output variable to use it later
- script: |
source output_analyze_static_sql.properties #read and fetch the return code from output file
echo "##vso[task.setvariable variable=staticRetCode]$staticSqlRC" #set the return code in output var
condition: succeededOrFailed()
displayName: 'Return Code-Static SQL'##
# Execute application step - analyzeDynamicSql (dynamic_sql)
- script: |
step dynamic_sql Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
condition: succeededOrFailed()
displayName: 'SQL Assurance - Analyze Dynamic SQL'
# Fetch the return code from output file output_analyze_dynamic_sql.properties
# and set in output variable to use it later
- script: |
source output_analyze_dynamic_sql.properties #read and fetch the return code from output file
echo "##vso[task.setvariable variable=dynamicRetCode]$dynamicSqlRC" #set the return code in output var
condition: succeededOrFailed()
displayName: 'Return Code-Dynamic SQL'##
### Pipeline_SQL_Assurance_Static_Dynamic_SQL_Sample.yml (for Azure DevOps)
###
# The sample pipeline performs Authentication + Static SQL (Package) + Dynamic SQL steps using application defined command step.
# The purpose of the pipeline is to extract the return code from the respective output file. Once extracted, it can be used in the
# pipeline to decide the execution of the subsequent steps.
# The sample pipeline script is defined to use various items like below:
# a) References to variables added in Variable group.
# b) Use of Linux based sed command to replace input as variable name by variable definition from pipeline.
# c) Use of configuration files (Config_SQL_Assurance_Static_SQL.yml & Config_SQL_Assurance_Dynamic_SQL.yml), that reside in directory (non-root folder).
# Example of properties of authentication step is taken from config file "Config_SQL_Assurance_Static_SQL.yml", that is
# maintained inside folders "Azure/SAMPLE/MAA/configFiles":
# step authentication Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
###
trigger:
- none #manual trigger of the pipeline
resources:
containers:
- container: my_container
image:attach:xwiki:Mainframe.Data-for-Db2.BMC-AMI-SQL-Assurance-for-Db2.COB13100.Command-and-syntax-reference.Universal-Connector-samples-in-BMC-AMI-SQL-Assurance.Sample-pipeline-scripts-for-Azure-DevOps.WebHome@filename <Image location>/sqlassuranceuc:13.01.00.0001-GA
options: -u root #run the container as root user
variables:
- group: AA_SAMPLE #name of the Variable group
pool:
name: <name of the agent pool> # name of the agent pool
stages:
- stage: 'Analyze_SQL_Statements'
displayName: 'Analyze SQL Statements'
jobs:
- job: 'Static_Dynamic_SQL'
displayName: 'Static and Dynamic SQL Job'
container: my_container
steps:
# For certBased Authentication, uncomment the following task to download the client certificate
# stored under Azure Pipelines --> Library --> Secure files
# - task: DownloadSecureFile@1
# name: clientCertificate
# displayName: 'Download p12 client certificate'
# inputs:
# secureFile: '<clientCertificateName>.p12'
# Perform various initialization functions using Linux based command sed
- script: |
echo "Replace variables defined in Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml file"
# Linux command sed is used to replace the config file variables with variables defined in Variable group
sed -i "s/USER_ID_AUTH/$(user_id)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
sed -i "s/USER_PASS_AUTH/$(user_pass)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
# For certBased Authentication, uncomment the following 2 sed commands
# sed -i "s|CERT_PATH_AUTH|$(clientCertificate.secureFilePath)|" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
# sed -i "s/CERT_PASS_AUTH/$(cert_pass)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
# Use Azure DevOps environment variables to fetch pipeline name, run number, run by and run mode of the executing pipeline
sed -i "s/PIPELINENAME_VALUE/$(Build.DefinitionName)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNNUMBER_VALUE/$(Build.BuildNumber)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNBY_VALUE/$(Build.RequestedFor)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNMODE_VALUE/$(Build.Reason)/" Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
echo "- Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml file is updated -"
displayName: 'Initialization'
# Execute application step - authentication
- script: |
step authentication Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
displayName: 'Authentication'
# Execute application step - analyzeStaticSql (static_sql_package)
- script: |
step static_sql_package Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Static_SQL.yml
displayName: 'SQL Assurance - Analyze Static SQL'
# Fetch the return code from output file output_analyze_static_sql.properties
# and set in output variable to use it later
- script: |
source output_analyze_static_sql.properties #read and fetch the return code from output file
echo "##vso[task.setvariable variable=staticRetCode]$staticSqlRC" #set the return code in output var
condition: succeededOrFailed()
displayName: 'Return Code-Static SQL'##
# Execute application step - analyzeDynamicSql (dynamic_sql)
- script: |
step dynamic_sql Azure/SAMPLE/MAA/configFiles/Config_SQL_Assurance_Dynamic_SQL.yml
condition: succeededOrFailed()
displayName: 'SQL Assurance - Analyze Dynamic SQL'
# Fetch the return code from output file output_analyze_dynamic_sql.properties
# and set in output variable to use it later
- script: |
source output_analyze_dynamic_sql.properties #read and fetch the return code from output file
echo "##vso[task.setvariable variable=dynamicRetCode]$dynamicSqlRC" #set the return code in output var
condition: succeededOrFailed()
displayName: 'Return Code-Dynamic SQL'##
Sample pipeline script for SQL Assurance Static SQL
The following figure represents a sample pipeline script for SQL Assurance Static SQL:
###
### Pipeline_SQL_Assurance_Static_SQL_Sample.yml (for Azure DevOps)
###
# The sample pipeline performs Authentication + Static SQL steps using application defined command step.
# The sample pipeline script is defined to use various items like below:
# a) References to variables added through Azure DevOps pipeline variable.
# b) Use of Linux based sed command to replace input as variable name by variable definition from pipeline.
# c) Use of configuration file (Config_SQL_Assurance_Static_SQL.yml), that is maintained in default root folder.
# Example of properties of authentication step is taken from Config_SQL_Assurance_Static_SQL.yml file:
# step authentication Config_SQL_Assurance_Static_SQL.yml
# Note: If pipeline executes with default configuration file name config.yml, that is maintained in root folder, then file name is not required in step command.
# Example of properties of authentication step is taken from default file name config.yml maintained in root folder:
# step authentication
###
trigger:
- none #manual trigger of the pipeline
resources:
containers:
- container: my_container
image:attach:xwiki:Mainframe.Data-for-Db2.BMC-AMI-SQL-Assurance-for-Db2.COB13100.Command-and-syntax-reference.Universal-Connector-samples-in-BMC-AMI-SQL-Assurance.Sample-pipeline-scripts-for-Azure-DevOps.WebHome@filename <Image location>/sqlassuranceuc:13.01.00.0001-GA
options: -u root #run the container as root user
pool: <name of the agent pool> #name of the agent pool
container: my_container
steps:
# For certBased Authentication, uncomment the following task to download the client certificate stored
# under Azure Pipelines --> Library --> Secure files
# - task: DownloadSecureFile@1
# name: clientCertificate
# displayName: 'Download p12 client certificate'
# inputs:
# secureFile: '<clientCertificateName>.p12'
# Perform various initialization functions using Linux based command sed
- script: |
echo "Replace variables defined in Config_SQL_Assurance_Static_SQL.yml file"
# Linux command sed is used to replace the config file variables with Azure DevOps pipeline variables
sed -i "s/USER_ID_AUTH/$(user_id)/" Config_SQL_Assurance_Static_SQL.yml
sed -i "s/USER_PASS_AUTH/$(user_pass)/" Config_SQL_Assurance_Static_SQL.yml
# For certBased Authentication, uncomment the following 2 sed commands
# sed -i "s|CERT_PATH_AUTH|$(clientCertificate.secureFilePath)|" Config_SQL_Assurance_Static_SQL.yml
# sed -i "s/CERT_PASS_AUTH/$(cert_pass)/" Config_SQL_Assurance_Static_SQL.yml
# Use Azure DevOps environment variables to fetch pipeline name, run number, run by and run mode of the executing pipeline
sed -i "s/PIPELINENAME_VALUE/$(Build.DefinitionName)/" Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNNUMBER_VALUE/$(Build.BuildNumber)/" Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNBY_VALUE/$(Build.RequestedFor)/" Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNMODE_VALUE/$(Build.Reason)/" Config_SQL_Assurance_Static_SQL.yml
echo "- Config_SQL_Assurance_Static_SQL.yml file is updated -"
displayName: 'Initialization'
# Execute application step - authentication
- script: |
step authentication Config_SQL_Assurance_Static_SQL.yml
displayName: 'Authentication'
# Execute application step - analyzeStaticSql (static_sql_package)
- script: |
step static_sql_package Config_SQL_Assurance_Static_SQL.yml
displayName: 'SQL Assurance - Analyze Static SQL'
### Pipeline_SQL_Assurance_Static_SQL_Sample.yml (for Azure DevOps)
###
# The sample pipeline performs Authentication + Static SQL steps using application defined command step.
# The sample pipeline script is defined to use various items like below:
# a) References to variables added through Azure DevOps pipeline variable.
# b) Use of Linux based sed command to replace input as variable name by variable definition from pipeline.
# c) Use of configuration file (Config_SQL_Assurance_Static_SQL.yml), that is maintained in default root folder.
# Example of properties of authentication step is taken from Config_SQL_Assurance_Static_SQL.yml file:
# step authentication Config_SQL_Assurance_Static_SQL.yml
# Note: If pipeline executes with default configuration file name config.yml, that is maintained in root folder, then file name is not required in step command.
# Example of properties of authentication step is taken from default file name config.yml maintained in root folder:
# step authentication
###
trigger:
- none #manual trigger of the pipeline
resources:
containers:
- container: my_container
image:attach:xwiki:Mainframe.Data-for-Db2.BMC-AMI-SQL-Assurance-for-Db2.COB13100.Command-and-syntax-reference.Universal-Connector-samples-in-BMC-AMI-SQL-Assurance.Sample-pipeline-scripts-for-Azure-DevOps.WebHome@filename <Image location>/sqlassuranceuc:13.01.00.0001-GA
options: -u root #run the container as root user
pool: <name of the agent pool> #name of the agent pool
container: my_container
steps:
# For certBased Authentication, uncomment the following task to download the client certificate stored
# under Azure Pipelines --> Library --> Secure files
# - task: DownloadSecureFile@1
# name: clientCertificate
# displayName: 'Download p12 client certificate'
# inputs:
# secureFile: '<clientCertificateName>.p12'
# Perform various initialization functions using Linux based command sed
- script: |
echo "Replace variables defined in Config_SQL_Assurance_Static_SQL.yml file"
# Linux command sed is used to replace the config file variables with Azure DevOps pipeline variables
sed -i "s/USER_ID_AUTH/$(user_id)/" Config_SQL_Assurance_Static_SQL.yml
sed -i "s/USER_PASS_AUTH/$(user_pass)/" Config_SQL_Assurance_Static_SQL.yml
# For certBased Authentication, uncomment the following 2 sed commands
# sed -i "s|CERT_PATH_AUTH|$(clientCertificate.secureFilePath)|" Config_SQL_Assurance_Static_SQL.yml
# sed -i "s/CERT_PASS_AUTH/$(cert_pass)/" Config_SQL_Assurance_Static_SQL.yml
# Use Azure DevOps environment variables to fetch pipeline name, run number, run by and run mode of the executing pipeline
sed -i "s/PIPELINENAME_VALUE/$(Build.DefinitionName)/" Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNNUMBER_VALUE/$(Build.BuildNumber)/" Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNBY_VALUE/$(Build.RequestedFor)/" Config_SQL_Assurance_Static_SQL.yml
sed -i "s/RUNMODE_VALUE/$(Build.Reason)/" Config_SQL_Assurance_Static_SQL.yml
echo "- Config_SQL_Assurance_Static_SQL.yml file is updated -"
displayName: 'Initialization'
# Execute application step - authentication
- script: |
step authentication Config_SQL_Assurance_Static_SQL.yml
displayName: 'Authentication'
# Execute application step - analyzeStaticSql (static_sql_package)
- script: |
step static_sql_package Config_SQL_Assurance_Static_SQL.yml
displayName: 'SQL Assurance - Analyze Static SQL'
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*