Skip to content

Commit

Permalink
add static code analysis to build step as a flaggable feature - check…
Browse files Browse the repository at this point in the history
… DB not required
  • Loading branch information
aguard-redgate committed Feb 27, 2024
1 parent 9d0caf6 commit eba2223
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ stages:
parameters:
stage: Build
displayName: Deploy Build
cleanBuildDB: true # Optional flag. Defaults to false
targetCredentials: redgate_build_credentials
pipelineParameters: redgate_pipeline_vars
cleanBuildDB: false
executeStaticCodeAnalysis: true
targetCredentials: newworlddb_build_credentials
pipelineParameters: newworlddb_pipeline_vars
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ parameters:
default: ''
- name: pipelineParameters
default: ''
- name: executeStaticCodeAnalysis
default: false

stages:
- stage: Build
Expand All @@ -21,6 +23,10 @@ stages:
- group: ${{parameters.pipelineParameters}}
- group: redgate_global_vars
steps:
# https://github.com/microsoft/azure-pipelines-yaml/blob/master/design/checkout-path.md#control-the-checkout-location-of-code
- checkout: templates
- checkout: self
name: source

- script: '$(FLYWAY) clean info -url="$(target_database_JDBC)"'
continueOnError: false
Expand All @@ -33,6 +39,21 @@ stages:
continueOnError: false
displayName: 'Validate Migrate Scripts'

- script: '$(FLYWAY) info check -check.rulesLocation="$(Build.SourcesDirectory)\templates\rules" -code -url="$(target_database_JDBC)" -reportFilename="$(System.ArtifactsDirectory)\$(databaseName)-$(Build.BuildId)-$(DRIFT_AND_CHANGE_REPORT)" -locations="filesystem:$(WORKING_DIRECTORY)\$(Build.Repository.Name)\migrations"'
continueOnError: false
workingDirectory: '$(WORKING_DIRECTORY)\$(Build.Repository.Name)'
displayName: '$(DRIFT_AND_CHANGE_REPORT_DISPLAY_NAME)'
condition: and(succeeded(), eq('${{ parameters.executeStaticCodeAnalysis }}', true))
env:
FLYWAY_CLEAN_DISABLED: false

- task: PublishBuildArtifacts@1
displayName: 'Publish $(DRIFT_AND_CHANGE_REPORT_DISPLAY_NAME)'
condition: and(succeeded(), eq('${{ parameters.executeStaticCodeAnalysis }}', true))
inputs:
ArtifactName: '$(DRIFT_AND_CHANGE_REPORT_DISPLAY_NAME)'
PathtoPublish: '$(System.ArtifactsDirectory)\$(databaseName)-$(Build.BuildId)-$(DRIFT_AND_CHANGE_REPORT)'

- script: '$(FLYWAY) undo info -url="$(target_database_JDBC)" -target="$(FIRST_UNDO_SCRIPT)"?'
continueOnError: true
displayName: 'Validate Undo Scripts'

0 comments on commit eba2223

Please sign in to comment.