将变量分配给 Azure 版本的 Shell 内联脚本

Assign a Variable to Shell inline script of Azure release

我有一个内联脚本,其中一个命令是下面的命令。我如何用 Azure 版本中的变量替换 LINUX_PASSWD。

我已将 LINUX_PASSWD 和 FILENAME 作为变量添加到 Azure 发布管道中,但在发布后它们为空

sed -i 's/password/$(LINUX_PASSWD)/g' FILENAME

如果您想用变量的值替换变量,请使用 $(varable_name) 模板。你的情况:

sed -i 's/password/$(LINUX_PASSWD)/g' $(FILENAME)

查看文档:Understand variable syntax, Using custom variables

To use custom variables in your build and release tasks, simply enclose the variable name in parentheses and precede it with a $ character. For example, if you have a variable named adminUserName, you can insert the current value of that variable into a parameter of a task as $(adminUserName).