...
Step 7: Create a Pipeline to run Packager
Use Create an Azure Pipeline to run the Deploy Packager (Build) job. Azure Pipelines are created from an azure_pipelines.yml file.
...
Code Block |
---|
trigger: none name: $(Application.Name)-$(Build.BuildId) variables: - template: ./variables.yml - group: Liquibase_Variables pool: name: $(Agent.PoolName) workspace: clean: all resources: repositories: - repository: DDB_REPOSITORY name: ABC_DDB type: git connection: AzureRepos source: ABC_DDB ref: 'refs/heads/main' - repository: SQL_REPOSITORY name: ABC_SQL type: git connection: AzureRepos source: ABC_SQL ref: 'refs/heads/current' - repository: CICD_REPOSITORY name: Liquibase/DB_CICD_PIPELINES type: git connection: AzureRepos source: Liquibase/DB_CICD_PIPELINES ref: 'refs/heads/main' - repository: CENTRALIZED_RULES_REPOSITORY name: Liquibase/CENTRALIZED_RULES type: git connection: AzureRepos source: Liquibase/CENTRALIZED_RULES ref: 'refs/heads/main' steps: - checkout: DDB_REPOSITORY persistCredentials: true clean: true - checkout: SQL_REPOSITORY clean: true fetchDepth: 100 persistCredentials: true - checkout: CENTRALIZED_RULES_REPOSITORY clean: true persistCredentials: true - script: | whoami hammer show version echo $(System.DefaultWorkingDirectory) printenv export PATH="$PATH:/opt/mssql-tools/bin"displayName: 'Run Prechecks' # Ensure the PATH includes the necessary executables, eg. hammer and sqlplus/sqlcmd/clpplus/psql # Also copy the Rules from the Centralized rules folder to the DDB folder - powershell: | $Env:Path += ";C:\Users\Administrator\DaticalDB\repl" $Env:Path += ";C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\" cd $(Git.Repository) xcopy /s/e/y ..\CENTRALIZED_RULES\Rules\. .\Rules\* condition: eq( variables['Agent.OS'], 'Windows_NT' ) displayName: 'Run PrechecksUpdate PATH (Windows) and set Rules' - script: | export PATH="$PATH:/opt/datical/DaticalDB/repl" export PATH="$PATH:/opt/mssql-tools/bin" cd $(Git.Repository) cp -R ../CENTRALIZED_RULES/Rules . condition: eq( variables['Agent.OS'], 'Linux' ) displayName: 'Update PATH (Linux) and set Rules' - script: | cd $(Git.Repository) printenv hammer groovy deployPackager.groovy pipeline=current commitPrefix="[skip ci]" scm=true labels=$(Build.BuildId),current if [ $? -ne 0 ]; then exit 1; fi displayName: 'Run Liquibase packager' env: DDB_USER: $(Liquibase-abc-ref1-User) DDB_PASS: $(Liquibase-abc-ref1-Pass) DDB_DMCDB_USER: $(Liquibase-abc-dmc-User) DDB_DMCDB_PASS: $(Liquibase-abc-dmc-Pass) # Compress files into .zip - scripttask: |ArchiveFiles@2 inputs: pwd cd rootFolderOrFile: '$(System.DefaultWorkingDirectory)/$(Git.Repository)' echo $nameincludeRootFolder: true zip -q -r $(Application.Name)-$(Build.BuildId).zip *archiveType: 'zip' mkdir -p archiveFile: '$(System.DefaultWorkingDirectory)/artifacts ls -l $(Application.Name)-$(Build.BuildId).zip cp /$(Application.Name)-$(Build.BuildId).zip $(System.DefaultWorkingDirectory)/artifacts displayName: 'Copy zip to Azure Artifacts' - upload: $(System.DefaultWorkingDirectory)/artifacts/$(Application.Name)-$(Build.BuildId).zip artifact: drop - task: ArtifactoryGenericUpload@2 inputs: artifactoryService: 'ArtifactoryCS' specSource: 'taskConfiguration' fileSpec: | { "files": [ { "pattern": "$(Git.Repository)artifacts/$(Application.Name)-$(Build.BuildId).zip", "target": "$(Project.Name)/$(Application.Name)/" } ] } replaceSpecVars: true specVars: '$(Application.Name),$(Build.BuildId)' collectBuildInfo: true buildName: '$(Build.DefinitionName)' buildNumber: '$(Build.BuildNumber)' module: '$(Project.Name)' failNoOp: true displayName: 'Upload zip to artifactory' - task: ArtifactoryPublishBuildInfo@1 inputs: artifactoryService: 'ArtifactoryCS' buildName: '$(Build.DefinitionName)' buildNumber: '$(Build.BuildNumber)' displayName: 'Publish Build Info to artifactory' - task: ArtifactoryBuildPromotion@1 inputs: artifactoryService: 'ArtifactoryCS' buildName: '$(Build.DefinitionName)' buildNumber: '$(Build.BuildNumber)' targetRepo: '$(Project.Name)' status: 'Released' sourceRepo: '$(Project.Name)' includeDependencies: false copy: false dryRun: false displayName: 'Promote Build to artifactory' - task: AzureKeyVault@2 inputs: azureSubscription: 'CustomerSuccessPayAsGo' KeyVaultName: 'cs-key-vault1' SecretsFilter: '*' RunAsPreJob: true |
variables.yml file
Code Block |
---|
variables:
Project.Name: ABC
Application.Name: ABC-App
Git.Repository: ABC_DDB
Git.Repository2: ABC_SQL
Agent.PoolName: 'CS'
JFrog.EndPoint: 'JFrog-DevOps'
JFrog.Repository: 'abc'
App.Version: $(Build.BuildId)
Source.Branch: 'current'' |
Step 8: Create a Release to run Forecast and Deploy Jobs
...