简体   繁体   English

在 SQL 服务器部署任务中设置 Azure 管道变量值

[英]Set Azure Pipeline variable value in SQL Server Deployment task

在此处输入图像描述 I am using SQL Server Database Deployment task in azure release pipeline to take back up of the database I need to set backup filename/path in a pipeline variable to use it in another task under a different deployment group in the same stage to restore the DB in case of any release error.我在 azure 发布管道中使用 SQL 服务器数据库部署任务来备份数据库 我需要在管道变量中设置备份文件名/路径,以便在同一阶段的不同部署组下的另一个任务中使用它来恢复数据库在任何发布错误的情况下。

I already found a way to set variable value in "Run Inline powershell" task using ##vso[task.setvariable variable=variableName;]value我已经找到了一种使用##vso[task.setvariable variable=variableName;]value在“运行内联 powershell”任务中设置变量值的方法

But for SQL Server Deployment task, i couldn't find anything as such.但是对于 SQL 服务器部署任务,我找不到任何类似的东西。 "Settable at release time" flag is turned ON for the variable.变量的“可在发布时设置”标志打开。

Basically the requirement is to back up the Database and restore in case of any error in the DACPAC release.基本上,要求是备份数据库并在 DACPAC 版本中出现任何错误时恢复。 Please suggest a way to set the variable value in SQL Server Deployment task or any alternate way to achieve my requirement.请提出一种在 SQL 服务器部署任务中设置变量值的方法或任何替代方法来满足我的要求。 I need the value of SQL variable @FullPath in a Pipeline Variable dynamically set during the release time.我需要在发布期间动态设置的管道变量中的 SQL 变量 @FullPath 的值。

You need to add powershell script step before an create there your FullPath.在创建 FullPath 之前,您需要添加 powershell 脚本步骤。 Then assign it to variable (you aready know syntax) and from know you can use this variable in all next tasks.然后将它分配给变量(您已经知道语法)并且知道您可以在所有后续任务中使用此变量。

So in powershell step you need define this:所以在 powershell 步骤中你需要定义这个:

I'm not sure where did you get from @BackupPath but this also needs to be part below.我不确定你从@BackupPath那里得到的,但这也需要在下面。

$fullPath=$(DataContextDbName)$(ClientNode).BAK
##vso[task.setvariable variable=YourFullPath;]$fullPath

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 SQL 服务器部署任务中设置 Azure 管道变量值进行备份 - Set Azure Pipeline variable value in SQL Server Deployment task for backup Azure 管道启用基于变量值的任务 - Azure Pipeline Enable Task base on variable value .NET Core - 在Azure部署任务中设置环境变量 - .NET Core - Set Environment Variable in Azure Deployment Task 如何在 Azure Synapse 或数据工厂管道中设置和获取变量值 - How to set and get variable value in Azure Synapse or Data Factory pipeline Azure Pipeline - 如何使 delayForMinutes 任务使用变量中的值而不是硬编码值 - Azure Pipeline - How to make delayForMinutes task use value from variable instead of hardcoded value 如何在 Azure Devops 管道中的 YAML 中设置管道“任务版本” - How to set Pipeline 'Task version' in YAML in Azure Devops pipeline Azure Pipeline - Zip 部署 - Azure Pipeline - Zip deployment Azure 发布管道 - Azure 密钥保管库任务 VS 变量组 - Azure Release pipeline - Azure key vault task VS variable groups azure 管道 - 基于触发分支设置变量 - azure pipeline - set variable based on triggered branch azure流水线-根据触发路径设置变量 - azure pipeline - set a variable based on the trigger path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM