Error deploying a Sql Change Automation Build Artifact using Sync-DatabaseSchema cmdlet
CopperStarSystems
Posts: 10 New member
I'm in the process of configuring a Powershell CI/CD pipeline using the RedGate cmdlets.
Everything appears to be functioning correctly until I get to the Sync-DatabaseSchema step, which fails with this error message:
Sync-DatabaseSchema : The specified value for the InputObject parameter is neither a valid database connection string nor a path to an existing NuGet package file or scripts folder: 'RedGate.Versioning.Automation.Compare.Domain.BuildArtifacts.ScaBuildArtifact'
Per the documentation at https://documentation.red-gate.com/display/SCA3/Sync-DatabaseSchema (Example 2), I'm passing an SCA build artifact (imported using Import-DatabaseBuildArtifact) as the Source, and a database connection as the Target.
The script I'm working from is below:
# CI build/deploy of a Redgate database<br>Install-Module -Name SqlServer -Scope CurrentUser<br><br># NuGet<br>$packageVersion = "1.2.0"<br>$packageId = "Redgate.Sca.FromExistingDb"<br>$project = [String]::Format("{0}\{1}\{2}.sqlproj", (pwd), $packageId, $packageId)<br><br># Artifacts<br>$buildArtifactLocation = [String]::Format("{0}\DbArtifacts\Build", (pwd))<br>$releaseArtifactLocation = [String]::Format("{0}\DbArtifacts\Release", (pwd))<br>$fullBuildArtifactPath = ([String]::Format("{0}\{1}.{2}.nupkg", $buildArtifactLocation, $packageId, $packageVersion))<br><br># Deployment<br>$deploymentTargetServer = ".\SQLEXPRESS"<br>$deploymentTargetDb = "Redgate.Sca.CI.Staging"<br>$deploymentConnection = New-DatabaseConnection -ServerInstance $deploymentTargetServer -Database $deploymentTargetDb<br><br># ===== Build =====<br>Write-Host("Validating database project...")<br>$validatedProject = $project | Invoke-DatabaseBuild<br>$documentation = $validatedProject | New-DatabaseDocumentation<br><br>Write-Host("Building database Build artifact...")<br>$buildArtifact = $validatedProject | New-DatabaseBuildArtifact -PackageId $packageId -PackageVersion $packageVersion -Documentation $documentation <br><br>Write-Host("Exporting database Build artifact...")<br>$buildArtifact | Export-DatabaseBuildArtifact -Path $buildArtifactLocation -Force<br><br># ===== Release =====<br>Write-Host("Building database Release artifact...")<br><br>$releaseArtifact = New-DatabaseReleaseArtifact -Source $buildArtifact -Target $deploymentConnection<br>Write-Host $fullBuildArtifactPath<br>Write-Host $buildArtifact<br><br>Write-Host("Exporting database Release artifact...")<br>$releaseArtifact | Export-DatabaseReleaseArtifact -Path $releaseArtifactLocation -Force<br><br># ===== Deploy =====<br>Write-Host("Deploying database updates to target...")<br>Sync-DatabaseSchema -Source $buildArtifact -Target $deploymentConnection
Tagged:
Best Answer
-
Diogo Posts: 67 Silver 5Support for SCA build artifacts was built recently so you may not be on the latest version.
However I'd still suggest you use the Use-DatabaseReleaseArtifact cmdlet instead of Sync-DatabaseSchema
https://documentation.red-gate.com/display/SCA3/Use-DatabaseReleaseArtifact
Answers