【发布时间】:2021-08-01 23:12:53
【问题描述】:
我在constants.groovy 文件中有以下行:
myMap = [
"TEST":["SQL_URL":"Data Source=TEST,123", "credential":"" ]
]
jenkinsfile.groovy中的这一行:
bat "powershell.exe -file pipeline/powershell/deploy_sql.ps1 ${myMap[env.Environment_Type].SQL_URL}"
还有deploy_sql.ps1中的这一行:
$Env = $args[0]
$msbuild = Start-Process -FilePath "msbuild" -ArgumentList '"Database Services\Database Services.sqlproj"','/t:deploy','/p:Configuration=Release','/p:TargetConnectionString="Data Source="+$Env+";Integrated Security=True;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False"','/p:BlockOnPossibleDataLoss=True','/p:TargetDatabase="bnhp_fsdb"','-fl','-flp:logfile=msbuild.log' -wait -PassThru
但我在日志中收到此错误:
Deploy error Deploy72002: Unable to connect to target server '+$Env+'. Please verify the connection information such as the server name, login credentials, and firewall rules for the target server.
当我使用完整的硬编码数据源运行时,它可以工作,所以我猜 powershell 语法有问题
【问题讨论】:
标签: sql-server powershell jenkins-pipeline