找不到 Azure DevOps 管道迁移 SQL

Azure DevOps Pipeline Migrations SQL not found

我正在构建我的发布管道,其中包含一个阶段,用于将迁移部署到我自己服务器上的 SQL 服务器数据库。构建管道生成 .sql 脚本并将其发布到迁移文件夹

在发布管道中,我添加了一个名为 SQL Server database deploy 的任务并将路径设置为 .sql 文件

现在,如果我 运行 该管道,它 运行 会出错

[error]No files were found to deploy with search pattern D:\a\r1\a/drop/migrations/TimeServiceDataContext.sql

所以一定是提供的路径有误,但我找不到,可能是正确的。

这是调试输出

2020-06-14T21:00:46.9140268Z ##[debug]Evaluating condition for step: 'Deploy using : sqlQuery'
2020-06-14T21:00:46.9142671Z ##[debug]Evaluating: succeeded()
2020-06-14T21:00:46.9143229Z ##[debug]Evaluating succeeded:
2020-06-14T21:00:46.9144608Z ##[debug]=> True
2020-06-14T21:00:46.9145556Z ##[debug]Result: True
2020-06-14T21:00:46.9146106Z ##[section]Starting: Deploy using : sqlQuery
2020-06-14T21:00:46.9277557Z ==============================================================================
2020-06-14T21:00:46.9277903Z Task         : SQL Server database deploy
2020-06-14T21:00:46.9278185Z Description  : Deploy a SQL Server database using DACPAC or SQL scripts
2020-06-14T21:00:46.9278427Z Version      : 0.3.23
2020-06-14T21:00:46.9278632Z Author       : Microsoft Corporation
2020-06-14T21:00:46.9278995Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/sql-dacpac-deployment-on-machine-group
2020-06-14T21:00:46.9279376Z ==============================================================================
2020-06-14T21:00:48.0530812Z ##[debug]VstsTaskSdk 0.8.2 commit 
2020-06-14T21:00:48.2649638Z ##[debug]Entering D:\a\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d[=11=].3.23\Main.ps1.
2020-06-14T21:00:48.2752917Z ##[debug]Loading resource strings from: D:\a\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d[=11=].3.23\Task.json
2020-06-14T21:00:48.3003693Z ##[debug]Loaded 6 strings.
2020-06-14T21:00:48.3288927Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-06-14T21:00:48.3289509Z ##[debug]Loading resource strings from: D:\a\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d[=11=].3.23\Strings\resources.resjson\en-US\resources.resjson
2020-06-14T21:00:48.3331827Z ##[debug]Loaded 6 strings.
2020-06-14T21:00:48.3607995Z ##[debug]INPUT_TASKTYPE: 'sqlQuery'
2020-06-14T21:00:48.3663637Z ##[debug]INPUT_DACPACFILE: 'D:\a\r1\a'
2020-06-14T21:00:48.3665646Z ##[debug]INPUT_SQLFILE: 'D:\a\r1\a/drop/migrations/TimeServiceDataContext.sql'
2020-06-14T21:00:48.3680833Z ##[debug]INPUT_EXECUTEINTRANSACTION: 'false'
2020-06-14T21:00:48.3721277Z ##[debug] Converted to bool: False
2020-06-14T21:00:48.3755339Z ##[debug]INPUT_EXCLUSIVELOCK: 'false'
2020-06-14T21:00:48.3778148Z ##[debug] Converted to bool: False
2020-06-14T21:00:48.3809928Z ##[debug]INPUT_APPLOCKNAME (empty)
2020-06-14T21:00:48.3882461Z ##[debug]INPUT_INLINESQL (empty)
2020-06-14T21:00:48.3919370Z ##[debug]INPUT_TARGETMETHOD: 'server'
2020-06-14T21:00:48.3954451Z ##[debug]INPUT_SERVERNAME: '88.198.44.249'
2020-06-14T21:00:48.3990602Z ##[debug]INPUT_DATABASENAME: 'Stage.TimeService'
2020-06-14T21:00:48.4026165Z ##[debug]INPUT_AUTHSCHEME: 'sqlServerAuthentication'
2020-06-14T21:00:48.4050818Z ##[debug]INPUT_SQLUSERNAME: 'Zoo-Director'
2020-06-14T21:00:48.4083226Z ##[debug]INPUT_SQLPASSWORD: 'Daniel#2019!newS'
2020-06-14T21:00:48.4112120Z ##[debug]INPUT_CONNECTIONSTRING (empty)
2020-06-14T21:00:48.4138318Z ##[debug]INPUT_PUBLISHPROFILE (empty)
2020-06-14T21:00:48.4172155Z ##[debug]INPUT_ADDITIONALARGUMENTS (empty)
2020-06-14T21:00:48.4205938Z ##[debug]INPUT_ADDITIONALARGUMENTSSQL (empty)
2020-06-14T21:00:48.4240088Z ##[debug]Loading module from path 'D:\a\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d[=11=].3.23\ps_modules\TaskModuleSqlUtility\TaskModuleSqlUtility.psd1'.
2020-06-14T21:00:48.4269587Z ##[debug]Loading module from path 'D:\a\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d[=11=].3.23\ps_modules\TaskModuleSqlUtility\TaskModuleSqlUtility.psm1'.
2020-06-14T21:00:48.4423108Z ##[debug]NonInteractive: False
2020-06-14T21:00:48.6017509Z ##[debug]Exporting function 'Invoke-DacpacDeployment'.
2020-06-14T21:00:48.6044940Z ##[debug]Exporting function 'Invoke-SqlQueryDeployment'.
2020-06-14T21:00:48.6091408Z ##[debug]Adding exceptions types.
2020-06-14T21:00:50.8081584Z ##[debug]Importing function 'Invoke-DacpacDeployment'.
2020-06-14T21:00:50.8099297Z ##[debug]Importing function 'Invoke-SqlQueryDeployment'.
2020-06-14T21:00:50.8847884Z ##[debug]Processed: ##vso[telemetry.publish area=SqlDacpacDeploymentOnMachineGroup;feature=SqlDacpacDeploymentOnMachineGroup]{"serverName": "56531c73afc443fce9712faf6ea6473e2b28f77562757d20dc806bf6549c3b0e","databaseName": "a44f4ee78fc10bbef97ea36bc9819a0a47d0e11f6a0aa5cedd395548086fa4e5"}
2020-06-14T21:00:50.9277590Z ##[debug]Finding files with pattern D:\a\r1\a/drop/migrations/TimeServiceDataContext.sql
2020-06-14T21:00:50.9331163Z ##[debug]Entering Find-VstsFiles.
2020-06-14T21:00:50.9388734Z ##[debug] LegacyPattern: 'D:\a\r1\a/drop/migrations/TimeServiceDataContext.sql'
2020-06-14T21:00:50.9831065Z ##[debug]Entering Get-MatchingItems.
2020-06-14T21:00:50.9873935Z ##[debug] IncludePatterns: 'D:\a\r1\a/drop/migrations/TimeServiceDataContext.sql'
2020-06-14T21:00:50.9931616Z ##[debug] ExcludePatterns: ''
2020-06-14T21:00:50.9981552Z ##[debug] IncludeFiles: 'True'
2020-06-14T21:00:51.0003180Z ##[debug] IncludeDirectories: 'False'
2020-06-14T21:00:51.0031742Z ##[debug] Force: 'False'
2020-06-14T21:00:51.2179973Z ##[debug]No paths.
2020-06-14T21:00:51.2213869Z ##[debug]Leaving Get-MatchingItems.
2020-06-14T21:00:51.2233073Z ##[debug]Total found: 0
2020-06-14T21:00:51.2257660Z ##[debug]Leaving Find-VstsFiles.
2020-06-14T21:00:51.2275406Z ##[debug]Matched files = 
2020-06-14T21:00:51.3304392Z ##[debug]Write-Exception error:
2020-06-14T21:00:51.3348086Z ##[debug]No files were found to deploy with search pattern D:\a\r1\a/drop/migrations/TimeServiceDataContext.sql
2020-06-14T21:00:51.3538650Z ##[debug]Caught exception from task script.
2020-06-14T21:00:51.3575755Z ##[debug]Error record:
2020-06-14T21:00:51.4275609Z ##[debug]No files were found to deploy with search pattern D:\a\r1\a/drop/migrations/TimeServiceDataContext.sql
2020-06-14T21:00:51.4293155Z ##[debug]At D:\a\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d[=11=].3.23\Main.ps1:51 char:13
2020-06-14T21:00:51.4294350Z ##[debug]+             throw (Get-VstsLocString -Key "Nofileswerefoundtodeploywi ...
2020-06-14T21:00:51.4295348Z ##[debug]+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-06-14T21:00:51.4307202Z ##[debug]    + CategoryInfo          : OperationStopped: (No files were f...DataContext.sql:String) [], RuntimeException
2020-06-14T21:00:51.4319906Z ##[debug]    + FullyQualifiedErrorId : No files were found to deploy with search pattern D:\a\r1\a/drop/migrations/TimeServiceD    ataContext.sql
2020-06-14T21:00:51.4330337Z ##[debug] 
2020-06-14T21:00:51.4356258Z ##[debug]Script stack trace:
2020-06-14T21:00:51.4395383Z ##[debug]at Get-SingleFile, D:\a\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d[=11=].3.23\Main.ps1: line 51
2020-06-14T21:00:51.4407230Z ##[debug]at <ScriptBlock>, D:\a\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d[=11=].3.23\Main.ps1: line 175
2020-06-14T21:00:51.4422508Z ##[debug]at <ScriptBlock>, <No file>: line 1
2020-06-14T21:00:51.4440151Z ##[debug]at <ScriptBlock>, <No file>: line 22
2020-06-14T21:00:51.4454203Z ##[debug]at <ScriptBlock>, <No file>: line 18
2020-06-14T21:00:51.4478858Z ##[debug]at <ScriptBlock>, <No file>: line 1
2020-06-14T21:00:51.4497567Z ##[debug]Exception:
2020-06-14T21:00:51.4549822Z ##[debug]System.Management.Automation.RuntimeException: No files were found to deploy with search pattern D:\a\r1\a/drop/migrations/TimeServiceDataContext.sql
2020-06-14T21:00:51.4853912Z ##[error]No files were found to deploy with search pattern D:\a\r1\a/drop/migrations/TimeServiceDataContext.sql
2020-06-14T21:00:51.4865099Z ##[debug]Processed: ##vso[task.logissue type=error]No files were found to deploy with search pattern D:\a\r1\a/drop/migrations/TimeServiceDataContext.sql
2020-06-14T21:00:51.4867288Z ##[debug]Processed: ##vso[task.complete result=Failed]
2020-06-14T21:00:51.5269963Z ##[section]Finishing: Deploy using : sqlQuery

OP 已更新:

运行他自己的机器上的任务终于解决了问题。


(Required) Location of the SQL file on the target. Provide semi-colon separated list of SQL script files to execute multiple files. The SQL scripts will be executed in the order given. Location can also be a UNC path like, \BudgetIT\Web\Deploy\FabrikamDB.sql. The UNC path should be accessible to the machine's administrator account. Environment variables are also supported, such as $env:windir, $env:systemroot, $env:windir\FabrikamFibre\DB. Wildcards can be used. For example, /*.sql for sql file present in all sub folders

Source Link

你应该使用“\”。通常,路径如下所示:

 $(System.DefaultWorkingDirectory)\[Artifact name]\migrations\TimeServiceDataContext.sql

如果您使用的是默认掉落名称,它将直接是

D:\a\r1\a\migrations\TimeServiceDataContext.sql

此外,您似乎使用的是自托管代理,您也可以直接远程访问托管构建代理的机器并检查有效的文件夹路径。