news /
Sample pipeline scripts for Azure DevOps - Documentation for BMC AMI DevOps for Db2 13.1
The sample pipelines are located in BMC-AMI Sample Folder in the Azure DevOps directory, which is the directory to which the BMC-AMI-DevOps-for-Db2-13.zip file is downloaded and extracted. For example:
C:\Users\userName\Downloads\BMC-AMI-DevOps-for-Db2-13\BMC AMI DevOps for Db2 13\Azure DevOps\BMC-AMI Sample Folder
Sample pipeline script for File Transmission
The following figure represents a sample pipeline script for File Transmission:
###------------------------------------------------------------------------------------------------------------------------------------
### Pipeline_File_Transmission_Sample.yml (for Azure DevOps)
###------------------------------------------------------------------------------------------------------------------------------------
# The sample pipeline performs Authentication + File Transmission 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_File_Transmission.yml), that is maintained in default root folder.
# Example of properties of authentication step is taken from Config_File_Transmission.yml file:
# step authentication Config_File_Transmission.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: <Image location>/devopsuc:13.01.00.0003-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_File_Transmission.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_File_Transmission.yml sed -i "s/USER_PASS_AUTH/$(user_pass)/" Config_File_Transmission.yml # For certBased Authentication, uncomment the following 2 sed commands # sed -i "s|CERT_PATH_AUTH|$(clientCertificate.secureFilePath)|" Config_File_Transmission.yml # sed -i "s/CERT_PASS_AUTH/$(cert_pass)/" Config_File_Transmission.yml # Use syntax \<var name\> to find and replace the exact matching word sed -i "s/\<JOB_ID\>/$(job_id)/" Config_File_Transmission.yml sed -i "s/DDL_FILE_FT_UPLOAD/$(ddl_file)/" Config_File_Transmission.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_File_Transmission.yml sed -i "s/RUNNUMBER_VALUE/$(Build.BuildNumber)/" Config_File_Transmission.yml sed -i "s/RUNBY_VALUE/$(Build.RequestedFor)/" Config_File_Transmission.yml sed -i "s/RUNMODE_VALUE/$(Build.Reason)/" Config_File_Transmission.yml echo "----- Config_File_Transmission.yml file is updated -----" displayName: 'Initialization'
# Execute application step - authentication
- script: | step authentication Config_File_Transmission.yml displayName: 'Authentication'
# Execute application step - fileUpload (local_to_mainframe)
- script: | step local_to_mainframe Config_File_Transmission.yml displayName: 'File Transmission'Sample pipeline script for Schema Migration
The following figure represents a sample pipeline script for Schema Migration:
###------------------------------------------------------------------------------------------------------------------------------------
### Pipeline_Schema Migration_Sample.yml (for Azure DevOps)
###------------------------------------------------------------------------------------------------------------------------------------
# The sample pipeline performs Authentication + File Transmission + Local Cat to DDL + Output Transmission + JCL Exec 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 file (Config_Schema_Migration_CompareDDL.yml), that resides in directory (non-root folder).
# Example of properties of authentication step is taken from config file "Config_Schema_Migration_CompareDDL.yml", that is
# maintained inside folders "Azure/SAMPLE/MAA/configFiles":
# step authentication Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.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: <Image location>/devopsuc:13.01.00.0003-GA options: -u root #run the container as root user
variables:
- group: AA_SAMPLE #name of the Variable group
- name: job_id #name of global variable value: AA121222 #value of global variable
pool: name: <name of the agent pool> # name of the agent pool
stages:
- stage: 'Implement_Schema_Changes' displayName: 'Implement Schema Changes' jobs: - job: 'schema_change' displayName: 'Schema Change 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_Schema_Migration_CompareDDL.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_Schema_Migration_CompareDDL.yml sed -i "s/USER_PASS_AUTH/$(user_pass)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml # For certBased Authentication, uncomment the following 2 sed commands # sed -i "s|CERT_PATH_AUTH|$(clientCertificate.secureFilePath)|" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml # sed -i "s/CERT_PASS_AUTH/$(cert_pass)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml # Use syntax \<var name\> to find and replace the exact matching word sed -i "s/\<JOB_ID\>/$(job_id)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml sed -i "s/DDL_FILE_FT_UPLOAD/$(ddl_file)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.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_Schema_Migration_CompareDDL.yml sed -i "s/RUNNUMBER_VALUE/$(Build.BuildNumber)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml sed -i "s/RUNBY_VALUE/$(Build.RequestedFor)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml sed -i "s/RUNMODE_VALUE/$(Build.Reason)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml echo "----- Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml file is updated -----" displayName: 'Initialization' # Execute application step - authentication - script: | step authentication Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml displayName: 'Authentication' # Execute application step - fileUpload (local_to_mainframe) - script: | step local_to_mainframe Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml displayName: 'Transfer DDL to mainframe' # Execute application step - localCatToDDL (localCat_to_DDL) - script: | step localCat_to_DDL Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml displayName: 'Schema Migration-Local Cat to DDL' # Fetch the return code from output file output_local_cat_ddl.properties # and set in output variable to use it later - script: | source output_local_cat_ddl.properties #read and fetch the return code from output file echo "##vso[task.setvariable variable=retCode]$compareRC" #set the return code in output var displayName: 'Return Code-Local Cat to DDL' # Execute application step - outputTransmission (download_output) - script: | step download_output Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml displayName: 'Download Files - CDL/WL/EXECJCL/IR' ### # Execute application step - jclExecutionUsingPDSMember (jclExecutionPDS) # Method-1: Using Azure DevOps based condition keyword- Run step only if condition is satisfied. ### - script: | step jclExecutionPDS Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml condition: and(succeeded(), le(variables['retCode'], '0004')) displayName: 'Run JCL to Implement Schema Change' ### # Execute application step - jclExecutionUsingPDSMember (jclExecutionPDS) # Method-2: Using bash script based IF...ELSE---FI keyword- Run step only if condition is satisfied. ### # - script: | # if [ "$(retCode)" -le "0004" ]; then # step jclExecutionPDS Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_CompareDDL.yml # else # echo "Condition is not satisfied, hence skip the run" # fi # displayName: 'Run JCL to Implement Schema Change'Sample pipeline script of Schema Migration and Schema Standards
The following figure represents a sample pipeline script of Schema Migration and Schema Standards:
###------------------------------------------------------------------------------------------------------------------------------------
### Pipeline_Schema_Migration_Schema_Standards_Sample.yml (for Azure DevOps)
###------------------------------------------------------------------------------------------------------------------------------------
# The sample pipeline performs Authentication + Local Cat to DDL + Schema Standards (schema type-CDL) 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_Schema_Migration_Schema_Standards.yml), that resides in directory (non-root folder).
# Example of properties of authentication step is taken from config file "Config_Schema_Migration_Schema_Standards.yml", that is
# maintained inside folders "Azure/SAMPLE/MAA/configFiles":
# step authentication Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.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: <Image location>/devopsuc:13.01.00.0003-GA options: -u root #run the container as root user
variables: - group: SS_SAMPLE #name of the Variable group - name: job_id #name of global variable value: SS121222 #value of global variable
pool: <name of the agent pool> #name of the agent pool
stages:
- stage: 'Schema_Migration_Schema_Standards' displayName: 'Schema Migration and Schema Standards' jobs: - job: 'schema_standards_cdl' displayName: 'Schema Standards-CDL 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_Schema_Migration_Schema_Standards.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_Schema_Migration_Schema_Standards.yml sed -i "s/USER_PASS_AUTH/$(user_pass)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.yml # For certBased Authentication, uncomment the following 2 sed commands # sed -i "s|CERT_PATH_AUTH|$(clientCertificate.secureFilePath)|" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.yml # sed -i "s/CERT_PASS_AUTH/$(cert_pass)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.yml # Use syntax \<var name\> to find and replace the exact matching word sed -i "s/\<JOB_ID\>/$(job_id)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.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_Schema_Migration_Schema_Standards.yml sed -i "s/RUNNUMBER_VALUE/$(Build.BuildNumber)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.yml sed -i "s/RUNBY_VALUE/$(Build.RequestedFor)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.yml sed -i "s/RUNMODE_VALUE/$(Build.Reason)/" Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.yml echo "----- Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.yml file is updated -----" displayName: 'Initialization' # Execute application step - authentication - script: | step authentication Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.yml displayName: 'Authentication' # Execute application step - localCatToDDL (localCat_to_DDL) - script: | step localCat_to_DDL Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.yml displayName: 'Schema Migration - Local Cat to DDL' # Fetch the return code from output file output_local_cat_ddl.properties # and set in output variable to use it later - script: | source output_local_cat_ddl.properties #read and fetch the return code from output file echo "##vso[task.setvariable variable=retCode]$compareRC" #set the return code in output var displayName: 'Return Code - Local Cat to DDL' ### # Execute application step - schemaStandards (schema_standards_cdl) # Method-1: Using Azure DevOps based condition keyword- Run step only if $compareRC condition is satisfied. ### - script: | step schema_standards_cdl Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.yml condition: and(succeeded(), le(variables['retCode'], '0004')) displayName: 'Schema Standards – Analyze CDL' ### # Execute application step - schemaStandards (schema_standards_cdl) # Method-2: Using bash script based IF...ELSE---FI keyword- Run step only if $compareRC condition is satisfied. ### # - script: | # if [ "$(retCode)" -le "0004" ]; then # step schema_standards_cdl Azure/SAMPLE/MAA/configFiles/Config_Schema_Migration_Schema_Standards.yml # else # echo "Condition is not satisfied, hence skip the run" # fi # displayName: 'Run JCL to Analyze CDL'Sample pipeline script of Schema Standards for DDL type
The following figure represents a sample pipeline script of Schema Standards for DDL type:
###------------------------------------------------------------------------------------------------------------------------------------
### Pipeline_Schema_Standards_Schema_Type_DDL_Sample.yml (for Azure DevOps)
###------------------------------------------------------------------------------------------------------------------------------------
# The sample pipeline performs Authentication + Schema Standards (schema type-DDL) 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_Schema_Standards_Schema_Type_DDL.yml), that is maintained in default root folder.
# Example of properties of authentication step is taken from Config_Schema_Standards_Schema_Type_DDL.yml file:
# step authentication Config_Schema_Standards_Schema_Type_DDL.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: <Image location>/devopsuc:13.01.00.0003-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_Schema_Standards_Schema_Type_DDL.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_Schema_Standards_Schema_Type_DDL.yml sed -i "s/USER_PASS_AUTH/$(user_pass)/" Config_Schema_Standards_Schema_Type_DDL.yml # For certBased Authentication, uncomment the following 2 sed commands # sed -i "s|CERT_PATH_AUTH|$(clientCertificate.secureFilePath)|" Config_Schema_Standards_Schema_Type_DDL.yml # sed -i "s/CERT_PASS_AUTH/$(cert_pass)/" Config_Schema_Standards_Schema_Type_DDL.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_Schema_Standards_Schema_Type_DDL.yml sed -i "s/RUNNUMBER_VALUE/$(Build.BuildNumber)/" Config_Schema_Standards_Schema_Type_DDL.yml sed -i "s/RUNBY_VALUE/$(Build.RequestedFor)/" Config_Schema_Standards_Schema_Type_DDL.yml sed -i "s/RUNMODE_VALUE/$(Build.Reason)/" Config_Schema_Standards_Schema_Type_DDL.yml echo "----- Config_Schema_Standards_Schema_Type_DDL.yml file is updated -----" displayName: 'Initialization'
# Execute application step - authentication
- script: | step authentication Config_Schema_Standards_Schema_Type_DDL.yml displayName: 'Authentication'
# Execute application step - schemaStandards (schema_standards_ddl)
- script: | step schema_standards_ddl Config_Schema_Standards_Schema_Type_DDL.yml displayName: 'Schema Standards – Analyze DDL'