azure - Azure 管道运行时替换表达式
问题描述
我replace
在 azure 管道 yaml 文件中有两个相同的语句
- script: echo ${{ replace('refs/heads/origin', 'refs/heads', 'origin') }}
- script: echo $[ replace('refs/heads/origin', 'refs/heads', 'origin') ]
除了一个是运行时表达式,而另一个是编译时表达式。
虽然编译时表达式工作正常,但运行时表达式给了我以下错误
line 1: replace('refs/heads/origin', 'refs/heads', 'origin') : syntax error in expression (error token is "('refs/heads/origin', 'refs/heads', 'origin') ")
如何使运行时替换表达式正常工作?
解决方案
您应该为此使用一个变量:
variables:
runtimeTest: $[ replace('refs/heads/origin', 'refs/heads', 'origin') ]
然后您可以在script
没有错误的部分中引用它:
steps:
- script: echo $(runtimeTest)
推荐阅读
- c++ - 如何使用 typeinfo.name C++ 声明变量
- python - 如何使用python将数据插入只有两位小数的表中?
- reactjs - 如何使用单个切换按钮推送和删除具有 3 个三个属性的对象
- abap - 来自应用程序服务器目录 ABAP 的自定义搜索帮助
- java - 是否可以在同一个线程中等待回调?
- json - 我需要通过控制器传递 Json 来查看。如何?
- entity-framework - 实体框架 - 插入具有多对多映射的模型
- wifi - 是否有一种标准方法可以从路由器/dhcp 服务器以编程方式获取 dhcp 客户端表?
- c++ - `void`“对象”的非定义声明:C++ 标准的哪一部分禁止它们?或者是吗?
- python - 用不同的通道OpenCV保存图像