I’m using the Liquibase Template for SQL Server featured in Delivering Database DevOps with Liquibase and Octopus Deploy - YouTube and having a bit of trouble. When I do either the reporting or the applying steps I get the following error but it’s not enough detail to reveal what’s going wrong. Has anyone experienced this?
I tried using the Octopus.Calamari.CopyWorkingDirectoryIncludingKeyTo variable to copy the work folder however even though the log shows that it’s copying I get nothing.
Downloading Liquibase from https://github.com/liquibase/liquibase/releases/download/v4.9.1/liquibase-4.9.1.zip https://github.com/liquibase/liquibase/releases/download/v4.9.1/liquibase-additional-4.9.1.zip ...
14:55:00 Error | NotSpecified: Cannot find an overload for "Substring" and the argument count: "1".
14:55:00 Error | At C:\Octopus\Tentacle\Work\20220413145453-106733-109\Script.ps1:37 char:52
14:55:00 Error | + ... t\liquibase\$($downloadUrl.Substring($downloadUrl.LastIndexOf("/")))"
14:55:00 Error | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14:55:00 Error | at Get-Liquibase, C:\Octopus\Tentacle\Work\20220413145453-106733-109\Script.ps1: line 37
14:55:00 Error | at <ScriptBlock>, C:\Octopus\Tentacle\Work\20220413145453-106733-109\Script.ps1: line 382
14:55:00 Error | at <ScriptBlock>, <No file>: line 1
14:55:00 Error | at <ScriptBlock>, C:\Octopus\Tentacle\Work\20220413145453-106733-109\Octopus.FunctionAppenderContext.ps1: line 201
14:55:00 Error | at <ScriptBlock>, C:\Octopus\Tentacle\Work\20220413145453-106733-109\Bootstrap.Octopus.FunctionAppenderContext.ps1: line 2944
14:55:00 Error | at <ScriptBlock>, <No file>: line 1
14:55:00 Error | at <ScriptBlock>, <No file>: line 1
Thanks for pointing me in a better direction! I have gotten farther now. Working through a database access issue at the moment but I did have a question. It looks like I can’t specify the location of the change log. If I put a folder in the parameter it fails to find the file. It does find it if I don’t specify the folder but what happens if I have multiple files with the same name?
Say I wanted to use this as my parameter and folder structure:
I’m actually in it right now adding Azure Managed Identity as an authentication option. Let me do some experimentation to see if we can make that work for you.
The Get-ChangeLog function looks for the file specified so providing a path won’t work as written. If you change the filenames of the changelog like #{Octopus.Depoloyment.Tenant.name}_changelog.xml that would be one way of making it work.
Function Get-ChangeLog
{
# Define parameters
param ($FileName)
# Find file
$fileReference = (Get-ChildItem -Path $OctopusParameters["Octopus.Action.Package[liquibaseChangeSet].ExtractedPath"] -Recurse | Where-Object {$_.Name -eq $FileName})
# Check to see if something weas returned
if ($null -eq $fileReference)
{
# Not found
Write-Error "$FileName was not found in $PSScriptRoot or subfolders."
}
# Return the reference
return $fileReference
}
That’s how I’ve been going with it thus far and can roll with it. This is a POC so I can define how we’ll work with the change lists going forward. Thanks for taking a look.
@Shawn_Sesna it seems that if you use Windows Authentication and specify a “Connection query string parameter” it doesn’t concatenate correctly and leaves out a semicolon. I worked around it by prepending on the variable but thought I should mention it.
13:03:36 Info | Caused by: liquibase.exception.DatabaseException: Connection could not be created to jdbc:sqlserver://<SERVER>:1433;database=<DB>;;integratedSecurity=truetrustServerCertificate=true with driver com.microsoft.sqlserver.jdbc.SQLServerDriver. The property integratedSecurity does not contain a valid boolean value. Only true or false can be used.
Actually, that’s by design as the format differs by database technology. The help text for the input is currently Add additional parameters to the connection string URL. Example: ?useUnicode=true or ;AuthMech=1 I tried to show that the delimiter needs to be in the beginning, is there some language that might make that more clear?
A colleague actually added the parameter but looking at the instruction I missed it at first. I think rewording the instruction to “Add additional parameters with delimiter to the connection string URL. Example: ?useUnicode=true or ;AuthMech=1” might call it out more. Granted it will fail and you do easily see the culprit. It took me a moment to find only because I didn’t make the change.