Sample pipeline scripts for GitLab CI/CD
The following figures represent sample pipeline scripts for GitLab CI/CD:
The sample pipelines are located in AMI DevOps Sample Folder in the GitLab CI directory, which is the directory to which the BMC-AMI-DevOps-Version-13.1.00-for-Db2-UC.zip file is downloaded and extracted. For example:
C:\Users\userName\Downloads\BMC-AMI-DevOps-Version-13.1.00-for-Db2-UC.zip\BMC AMI DevOps Version 13.1.00 for Db2 - UC\GitLab CI\AMI DevOps Sample Folder
You can use BMC AMI DevOps return code variables as needed in your pipelines and workflows. For more information on using BMC AMI DevOps return code variables, see Using BMC AMI DevOps return code variables in your GitLab CI/CD pipeline script.
Sample pipeline script for File Transmission
The following figure represents a sample pipeline script for File Transmission.
Click here to view
### Pipeline_File_Transmission_Sample.yml (for GitLab CI/CD)
###
# 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 GitLab CI/CD variables and Pipeline variables.
# b) Use of Linux based sed command to replace input as variable name by variable definition from GitLab CI/CD variables and Pipeline variables.
# 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
###
# Variable declaration for the Pipeline
variables:
PIPELINE_NAME: "Pipeline_File_Transmission_Sample" # pipeline name
CONFIG_FILE: "Config_File_Transmission.yml" # config file name
image:attach:xwiki:Mainframe.Data-for-Db2.BMC-AMI-DevOps-for-Db2.AMA13100.Command-and-syntax-reference.Universal-Connector-samples-in-BMC-AMI-DevOps.Sample-pipeline-scripts-for-GitLab-CI-CD.WebHome@filename <Image location>/devopsuc:13.01.00.0008-GA # image name
stages:
- file_transmission # stage name
build-job: # job name
stage: file_transmission
# Perform various initialization functions
before_script:
# For certBased Authentication, uncomment the following unzip command to unzip the specified client certificate
# from repository into path specified with -d parameter (ex. /opt/secret)
# - echo "Unzip client certificate zip file"
# - unzip -P "$zip_cert_pass" <clientCertificateName>.zip -d /opt/secret
# Use the config file name variable
- echo "Replace variables defined in $CONFIG_FILE file"
# Linux command sed is used to replace the config file variables with GitLab CI/CD variables
- sed -i "s/USER_ID_AUTH/$user_id/" $CONFIG_FILE
- sed -i "s/USER_PASS_AUTH/$user_pass/" $CONFIG_FILE
# For certBased Authentication, uncomment the following 2 sed commands
# - sed -i "s|CERT_PATH_AUTH|/opt/secret/<clientCertificateName>.p12|" $CONFIG_FILE
# - sed -i "s/CERT_PASS_AUTH/$cert_pass/" $CONFIG_FILE
# Use syntax \<var name\> to find and replace the exact matching word
- sed -i "s/\<JOB_ID\>/$job_id/" $CONFIG_FILE
- sed -i "s/DDL_FILE_FT_UPLOAD/$ddl_file/" $CONFIG_FILE
# Use the pipeline name variable
- sed -i "s/PIPELINENAME_VALUE/$PIPELINE_NAME/" $CONFIG_FILE
# Use GitLab CI/CD environment variables to fetch pipeline id, run by and pipeline source of the executing pipeline
- sed -i "s/RUNNUMBER_VALUE/$CI_PIPELINE_ID/" $CONFIG_FILE
- sed -i "s/RUNBY_VALUE/$GITLAB_USER_LOGIN/" $CONFIG_FILE
- sed -i "s/RUNMODE_VALUE/$CI_PIPELINE_SOURCE/" $CONFIG_FILE
- echo "- $CONFIG_FILE.yml file is updated -"
script:
# Execute application step - authentication
- step authentication $CONFIG_FILE
# Execute application step - fileUpload (local_to_mainframe)
- step local_to_mainframe $CONFIG_FILE
tags:
- <runner tag name> # runner tag name
Sample pipeline script for Schema Migration
The following figure represents a sample pipeline script for Schema Migration.
Click here to view
### Pipeline_Schema_Migration_Sample.yml (for GitLab CI/CD)
###
# 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 through GitLab CI/CD variables and Pipeline variables.
# b) Use of Linux based sed command to replace input as variable name by variable definition from GitLab CI/CD variables and Pipeline variables.
# 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 folder "configFiles":
# - step authentication configFiles/Config_Schema_Migration_CompareDDL.yml
# d) Bash script based if...then...fi is used.
###
# Variable declaration for the Pipeline
variables:
PIPELINE_NAME: "Pipeline_Schema_Migration_Sample" # pipeline name
CONFIG_FILE: "configFiles/Config_Schema_Migration_CompareDDL.yml" # config file name
image:attach:xwiki:Mainframe.Data-for-Db2.BMC-AMI-DevOps-for-Db2.AMA13100.Command-and-syntax-reference.Universal-Connector-samples-in-BMC-AMI-DevOps.Sample-pipeline-scripts-for-GitLab-CI-CD.WebHome@filename <Image location>/devopsuc:13.01.00.0008-GA # image name
stages:
- schema_change # stage name
build-job: # job name
stage: schema_change
# Perform various initialization functions
before_script:
# For certBased Authentication, uncomment the following unzip command to unzip the specified client certificate
# from repository into path specified with -d parameter (ex. /opt/secret)
# - echo "Unzip client certificate zip file"
# - unzip -P "$zip_cert_pass" <clientCertificateName>.zip -d /opt/secret
# Use the config file name variable
- echo "Replace variables defined in $CONFIG_FILE file"
# Linux command sed is used to replace the config file variables with GitLab CI/CD variables
- sed -i "s/USER_ID_AUTH/$user_id/" $CONFIG_FILE
- sed -i "s/USER_PASS_AUTH/$user_pass/" $CONFIG_FILE
# For certBased Authentication, uncomment the following 2 sed commands
# - sed -i "s|CERT_PATH_AUTH|/opt/secret/<clientCertificateName>.p12|" $CONFIG_FILE
# - sed -i "s/CERT_PASS_AUTH/$cert_pass/" $CONFIG_FILE
# Use syntax \<var name\> to find and replace the exact matching word
- sed -i "s/\<JOB_ID\>/$job_id/" $CONFIG_FILE
- sed -i "s/DDL_FILE_FT_UPLOAD/$ddl_file/" $CONFIG_FILE
# Use the pipeline name variable
- sed -i "s/PIPELINENAME_VALUE/$PIPELINE_NAME/" $CONFIG_FILE
# Use GitLab CI/CD environment variables to fetch pipeline id, run by and pipeline source of the executing pipeline
- sed -i "s/RUNNUMBER_VALUE/$CI_PIPELINE_ID/" $CONFIG_FILE
- sed -i "s/RUNBY_VALUE/$GITLAB_USER_LOGIN/" $CONFIG_FILE
- sed -i "s/RUNMODE_VALUE/$CI_PIPELINE_SOURCE/" $CONFIG_FILE
- echo "- $CONFIG_FILE.yml file is updated -"
script:
# Execute application step - authentication
- step authentication $CONFIG_FILE
# Execute application step - fileUpload (local_to_mainframe)
- step local_to_mainframe $CONFIG_FILE
# Execute application step - localCatToDDL (localCat_to_DDL)
- step localCat_to_DDL $CONFIG_FILE
# Perform the functions after finishing all application steps
# Load the environment variables from output file output_local_cat_ddl.properties
# Execute subsequent steps (download_output and jclExecutionPDS) only if the return code condition is satisfied
after_script:
- . output_local_cat_ddl.properties # source the output properties file to set environment variables
- echo "retCode=$compareRC" # print the return code value from the environment variable
- if [ "$compareRC" -le "0004" ]; then step download_output $CONFIG_FILE; fi
- if [ "$compareRC" -le "0004" ]; then step jclExecutionPDS $CONFIG_FILE; fi
tags:
- <runner tag name> # runner tag name
Sample pipeline script of Schema Migration and Schema Standards
The following figure represents a sample pipeline script of Schema Migration and Schema Standards.
Click here to view
### Pipeline_Schema_Migration_Schema_Standards_Sample.yml (for GitLab CI/CD)
###
# 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 through GitLab CI/CD variables and Pipeline variables.
# b) Use of Linux based sed command to replace input as variable name by variable definition from GitLab CI/CD variables and Pipeline variables.
# 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 folder "configFiles":
# - step authentication configFiles/Config_Schema_Migration_Schema_Standards.yml
# d) Bash script based if...then...fi is used.
###
# Variable declaration for the Pipeline
variables:
PIPELINE_NAME: "Pipeline_Schema_Migration_Schema_Standards_Sample" # pipeline name
CONFIG_FILE: "configFiles/Config_Schema_Migration_Schema_Standards.yml" # config file name
image:attach:xwiki:Mainframe.Data-for-Db2.BMC-AMI-DevOps-for-Db2.AMA13100.Command-and-syntax-reference.Universal-Connector-samples-in-BMC-AMI-DevOps.Sample-pipeline-scripts-for-GitLab-CI-CD.WebHome@filename <Image location>/devopsuc:13.01.00.0008-GA # image name
stages:
- schema_migration_schema_standards_cdl # stage name
build-job: # job name
stage: schema_migration_schema_standards_cdl
# Perform various initialization functions
before_script:
# For certBased Authentication, uncomment the following unzip command to unzip the specified client certificate
# from repository into path specified with -d parameter (ex. /opt/secret)
# - echo "Unzip client certificate zip file"
# - unzip -P "$zip_cert_pass" <clientCertificateName>.zip -d /opt/secret
# Use the config file name variable
- echo "Replace variables defined in $CONFIG_FILE file"
# Linux command sed is used to replace the config file variables with GitLab CI/CD variables
- sed -i "s/USER_ID_AUTH/$user_id/" $CONFIG_FILE
- sed -i "s/USER_PASS_AUTH/$user_pass/" $CONFIG_FILE
# For certBased Authentication, uncomment the following 2 sed commands
# - sed -i "s|CERT_PATH_AUTH|/opt/secret/<clientCertificateName>.p12|" $CONFIG_FILE
# - sed -i "s/CERT_PASS_AUTH/$cert_pass/" $CONFIG_FILE
# Use syntax \<var name\> to find and replace the exact matching word
- sed -i "s/\<JOB_ID\>/$job_id/" $CONFIG_FILE
# Use the pipeline name variable
- sed -i "s/PIPELINENAME_VALUE/$PIPELINE_NAME/" $CONFIG_FILE
# Use GitLab CI/CD environment variables to fetch pipeline id, run by and pipeline source of the executing pipeline
- sed -i "s/RUNNUMBER_VALUE/$CI_PIPELINE_ID/" $CONFIG_FILE
- sed -i "s/RUNBY_VALUE/$GITLAB_USER_LOGIN/" $CONFIG_FILE
- sed -i "s/RUNMODE_VALUE/$CI_PIPELINE_SOURCE/" $CONFIG_FILE
- echo "- $CONFIG_FILE.yml file is updated -"
script:
# Execute application step - authentication
- step authentication $CONFIG_FILE
# Execute application step - localCatToDDL (localCat_to_DDL)
- step localCat_to_DDL $CONFIG_FILE
# Perform the functions after finishing all application steps
# Load the environment variables from output file output_local_cat_ddl.properties
# Execute subsequent step (schema_standards_cdl) only if the return code condition is satisfied
after_script:
- . output_local_cat_ddl.properties # source the output properties file to set environment variables
- echo "retCode=$compareRC" # print the return code value from the environment variable
- if [ "$compareRC" -le "0004" ]; then step schema_standards_cdl $CONFIG_FILE; fi
tags:
- <runner tag name> # runner tag name
Sample pipeline script of Schema Standards for DDL type
The following figure represents a sample pipeline script of Schema Standards for DDL type.
Click here to view
### Pipeline_Schema_Standards_Schema_Type_DDL_Sample.yml (for GitLab CI/CD)
###
# 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 GitLab CI/CD variables and Pipeline variables.
# b) Use of Linux based sed command to replace input as variable name by variable definition from GitLab CI/CD variables and Pipeline variables.
# 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
###
# Variable declaration for the Pipeline
variables:
PIPELINE_NAME: "Pipeline_Schema_Standards_Schema_Type_DDL_Sample" # pipeline name
CONFIG_FILE: "Config_Schema_Standards_Schema_Type_DDL.yml" # config file name
image:attach:xwiki:Mainframe.Data-for-Db2.BMC-AMI-DevOps-for-Db2.AMA13100.Command-and-syntax-reference.Universal-Connector-samples-in-BMC-AMI-DevOps.Sample-pipeline-scripts-for-GitLab-CI-CD.WebHome@filename <Image location>/devopsuc:13.01.00.0008-GA # image name
stages:
- schema_standards_ddl # stage name
build-job: # job name
stage: schema_standards_ddl
# Perform various initialization functions
before_script:
# For certBased Authentication, uncomment the following unzip command to unzip the specified client certificate
# from repository into path specified with -d parameter (ex. /opt/secret)
# - echo "Unzip client certificate zip file"
# - unzip -P "$zip_cert_pass" <clientCertificateName>.zip -d /opt/secret
# Use the config file name variable
- echo "Replace variables defined in $CONFIG_FILE file"
# Linux command sed is used to replace the config file variables with GitLab CI/CD variables
- sed -i "s/USER_ID_AUTH/$user_id/" $CONFIG_FILE
- sed -i "s/USER_PASS_AUTH/$user_pass/" $CONFIG_FILE
# For certBased Authentication, uncomment the following 2 sed commands
# - sed -i "s|CERT_PATH_AUTH|/opt/secret/<clientCertificateName>.p12|" $CONFIG_FILE
# - sed -i "s/CERT_PASS_AUTH/$cert_pass/" $CONFIG_FILE
# Use the pipeline name variable
- sed -i "s/PIPELINENAME_VALUE/$PIPELINE_NAME/" $CONFIG_FILE
# Use GitLab CI/CD environment variables to fetch pipeline id, run by and pipeline source of the executing pipeline
- sed -i "s/RUNNUMBER_VALUE/$CI_PIPELINE_ID/" $CONFIG_FILE
- sed -i "s/RUNBY_VALUE/$GITLAB_USER_LOGIN/" $CONFIG_FILE
- sed -i "s/RUNMODE_VALUE/$CI_PIPELINE_SOURCE/" $CONFIG_FILE
- echo "- $CONFIG_FILE.yml file is updated -"
script:
# Execute application step - authentication
- step authentication $CONFIG_FILE
# Execute application step - schemaStandards (schema_standards_ddl)
- step schema_standards_ddl $CONFIG_FILE
tags:
- <runner tag name> # runner tag name
Sample pipeline script of Schema Standards for Impact Report using Work ID
The following figure represents a sample pipeline script of Schema Standards for Impact Report using Work ID.
Click here to view
### Pipeline_Schema_Standards_Schema_Type_Impact_Report_Sample.yml (for GitLab CI/CD)
###
# The sample pipeline performs Authentication + Schema Standards (schema type-impactReportUsingWorkId) steps using application defined command step.
# The sample pipeline script is defined to use various items like below:
# a) References to variables added through GitLab CI/CD variables and Pipeline variables.
# b) Use of Linux based sed command to replace input as variable name by variable definition from GitLab CI/CD variables and Pipeline variables.
# c) Use of configuration file (Config_Schema_Standards_Schema_Type_Impact_Report.yml), that is maintained in default root folder.
# Example of properties of authentication step is taken from Config_Schema_Standards_Schema_Type_Impact_Report.yml file:
# - step authentication Config_Schema_Standards_Schema_Type_Impact_Report.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
###
# Variable declaration for the Pipeline
variables:
PIPELINE_NAME: "Pipeline_Schema_Standards_Schema_Type_Impact_Report_Sample" # pipeline name
CONFIG_FILE: "Config_Schema_Standards_Schema_Type_Impact_Report.yml" # config file name
image:attach:xwiki:Mainframe.Data-for-Db2.BMC-AMI-DevOps-for-Db2.AMA13100.Command-and-syntax-reference.Universal-Connector-samples-in-BMC-AMI-DevOps.Sample-pipeline-scripts-for-GitLab-CI-CD.WebHome@filename <Image location>/devopsuc:13.01.00.0010-GA # image name
stages:
- schema_standards_impact_report # stage name
build-job: # job name
stage: schema_standards_impact_report
# Perform various initialization functions
before_script:
# For certBased Authentication, uncomment the following unzip command to unzip the specified client certificate
# from repository into path specified with -d parameter (ex. /opt/secret)
# - echo "Unzip client certificate zip file"
# - unzip -P "$zip_cert_pass" <clientCertificateName>.zip -d /opt/secret
# Use the config file name variable
- echo "Replace variables defined in $CONFIG_FILE file"
# Linux command sed is used to replace the config file variables with GitLab CI/CD variables
- sed -i "s/USER_ID_AUTH/$user_id/" $CONFIG_FILE
- sed -i "s/USER_PASS_AUTH/$user_pass/" $CONFIG_FILE
# For certBased Authentication, uncomment the following 2 sed commands
# - sed -i "s|CERT_PATH_AUTH|/opt/secret/<clientCertificateName>.p12|" $CONFIG_FILE
# - sed -i "s/CERT_PASS_AUTH/$cert_pass/" $CONFIG_FILE
# Use the pipeline name variable
- sed -i "s/PIPELINENAME_VALUE/$PIPELINE_NAME/" $CONFIG_FILE
# Use GitLab CI/CD environment variables to fetch pipeline id, run by and pipeline source of the executing pipeline
- sed -i "s/RUNNUMBER_VALUE/$CI_PIPELINE_ID/" $CONFIG_FILE
- sed -i "s/RUNBY_VALUE/$GITLAB_USER_LOGIN/" $CONFIG_FILE
- sed -i "s/RUNMODE_VALUE/$CI_PIPELINE_SOURCE/" $CONFIG_FILE
- echo "- $CONFIG_FILE.yml file is updated -"
script:
# Execute application step - authentication
- step authentication $CONFIG_FILE
# Execute application step - schemaStandards (schema_standards_impactReport)
- step schema_standards_impactReport $CONFIG_FILE
tags:
- <runner tag name> # runner tag name
-
13.1
- 12.1