VSTS版本定义中PowerShell脚本的硬编码参数 [英] Hardcode arguments to the PowerShell Script in VSTS Release definition

查看:71
本文介绍了VSTS版本定义中PowerShell脚本的硬编码参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有PowerShell脚本将csv文件部署到Azure表存储中.现在,我想在完成WebApp部署后在发布定义时在VSTS中配置这些脚本.因此,一旦完成Web应用程序部署,我将执行这些脚本脚本使用VSTS PowerShell任务.因此,我有6个环境,我的PowerShell脚本将必须部署到不同的Azure存储帐户(环境)中.因此,我需要针对不同的环境分别传递存储帐户名称,存储帐户密钥,资源组,但是我的PowerShell脚本是相同的.因此我可以在VSTS中使用PowerShell任务的参数字段传递这些参数.但是我不想使用该字段选项传递. VSTS的定义.请帮助我.

I have PowerShell scripts to deploy csv files into Azure tables storage.Now,I want to configure these scripts in VSTS at the release definition after the WebApp deployment is done.So once the web app deploy is done,I will execute these scripts using VSTS PowerShell task.So I have 6 environments ,My PowerShell script will have to be deployed into different azure storage accounts(Environments).So I need to pass the storage account name,storage account key,resource group separately for different environments but my PowerShell script will be the same.So I can pass these arguments using argument field of PowerShell task in VSTS.But I don't want to pass using that field option.So,Is there any best way to pass those arguments at the release definition of VSTS. Please help me on this.

推荐答案

简单的方法是使用环境变量:

The simple way is using environment variable:

  1. 为每个环境添加具有相同名称(不同值)的变量,例如storageAccountName
  1. Add variables with the same name (different value) for each environment, such as storageAccountName

  1. PowerShell任务,参数- storageAccountName $(storageAccountName)
  2. 中使用环境变量
  1. Using environment variables in PowerShell task, Arguments - storageAccountName $(storageAccountName)

这篇关于VSTS版本定义中PowerShell脚本的硬编码参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆