Skip to content

Commit

Permalink
Merge pull request #6 from red-gate/FWinstaller_corrections
Browse files Browse the repository at this point in the history
corrected yml name + powershell flyway installer
  • Loading branch information
AndrewGuard authored Jan 3, 2024
2 parents ad10293 + e09ed1c commit 1999768
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 47 deletions.
53 changes: 53 additions & 0 deletions Azure-Templatized-YML-Pipeline/templates/Install-Windows-fw.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#Flyway Version to Use - Check here for latest version information - https://documentation.red-gate.com/fd/command-line-184127404.html

$flywayVersion = '9.21.2'

#Flyway URL to download CLI

$Url = "https://download.red-gate.com/maven/release/org/flywaydb/enterprise/flyway-commandline/$flywayVersion/flyway-commandline-$flywayVersion-windows-x64.zip"

#Insert path for downloaded files

$DownloadZipFile = "C:\FlywayCLI\" + $(Split-Path -Path $Url -Leaf)

#Assign location for Flyway to extracted to

$ExtractPath = "C:\FlywayCLI\"

#SilentlyContinue informs PowerShell to download the CLI without a progress bar. This often drastically improves the download time.

$ProgressPreference = 'SilentlyContinue'

if (Test-Path $ExtractPath) {

Write-Host "Folder Exists"

}
else
{

#PowerShell Create directory if not exists
New-Item $ExtractPath -ItemType Directory
Write-Host "Folder Created successfully"
}

# Download the CLI to the desired location

Invoke-WebRequest -Uri $Url -OutFile $DownloadZipFile

# Extract the CLI to the desired location

$ExtractShell = New-Object -ComObject Shell.Application

$ExtractFiles = $ExtractShell.Namespace($DownloadZipFile).Items()

$ExtractShell.NameSpace($ExtractPath).CopyHere($ExtractFiles)
Start-Process $ExtractPath

# Update PATH Variable with Flyway CLI - Azure DevOps #

# echo "##vso[task.setvariable variable=path]$(PATH);C:\FlywayCLI\flyway-$flywayVersion"

# Update PATH variable with Flyway CLI - Generic - Comment above and uncomment below to take affect #

[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";${ExtractPath}flyway-$flywayVersion", [EnvironmentVariableTarget]::Machine)
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
parameters:
- name: stage
default: Build
- name: displayName
default: Deploy Build
- name: executeBuild
default: true
- name: targetCredentials
default: ''
- name: pipelineParameters
default: ''

stages:
- ${{if eq(parameters.executeBuild, true)}}:
- stage: Build
pool: $(AGENT_POOL)
displayName: ${{parameters.displayName}}
jobs:
- job: Build
variables:
- group: ${{parameters.targetCredentials}}
- group: ${{parameters.pipelineParameters}}
- group: redgate_global_vars
steps:
- bash: |
wget -q https://download.red-gate.com/maven/release/org/flywaydb/enterprise/flyway-commandline/9.22.3/flyway-commandline-9.22.3-linux-x64.tar.gz
tar -xzf flyway-commandline-9.22.3-linux-x64.tar.gz -C /opt
if [[ ! -L "/usr/local/bin/flyway" ]]
then
sudo ln -s /opt/flyway-9.22.3/flyway /usr/local/bin
fi
flyway --version
failOnStderr: true
displayName: 'Setup Redgate Flyway Commandline'
# - script: '$(FLYWAY) clean info -url="$(target_database_JDBC)"'
# failOnStderr: true
# displayName: 'Clean Build DB'
# env:
# FLYWAY_CLEAN_DISABLED: false

- script: '$(FLYWAY) migrate info -url="$(target_database_JDBC)"'
failOnStderr: true
displayName: 'Validate Migrate Scripts'

- script: '$(FLYWAY) undo info -url="$(target_database_JDBC)" -target="$(FIRST_UNDO_SCRIPT)"?'
continueOnError: true
parameters:
- name: stage
default: Build
- name: displayName
default: Deploy Build
- name: executeBuild
default: true
- name: targetCredentials
default: ''
- name: pipelineParameters
default: ''

stages:
- ${{if eq(parameters.executeBuild, true)}}:
- stage: Build
pool: $(AGENT_POOL)
displayName: ${{parameters.displayName}}
jobs:
- job: Build
variables:
- group: ${{parameters.targetCredentials}}
- group: ${{parameters.pipelineParameters}}
- group: redgate_global_vars
steps:
- bash: |
wget -q https://download.red-gate.com/maven/release/org/flywaydb/enterprise/flyway-commandline/9.22.3/flyway-commandline-9.22.3-linux-x64.tar.gz
tar -xzf flyway-commandline-9.22.3-linux-x64.tar.gz -C /opt
if [[ ! -L "/usr/local/bin/flyway" ]]
then
sudo ln -s /opt/flyway-9.22.3/flyway /usr/local/bin
fi
flyway --version
failOnStderr: true
displayName: 'Setup Redgate Flyway Commandline'
# - script: '$(FLYWAY) clean info -url="$(target_database_JDBC)"'
# failOnStderr: true
# displayName: 'Clean Build DB'
# env:
# FLYWAY_CLEAN_DISABLED: false

- script: '$(FLYWAY) migrate info -url="$(target_database_JDBC)"'
failOnStderr: true
displayName: 'Validate Migrate Scripts'

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

0 comments on commit 1999768

Please sign in to comment.