意外的符号包含'有条件地插入变量模板时
我无法弄清楚这个。任何帮助都将受到赞赏。这让我发疯,不确定我在做什么错。
我尝试用“ eq”和“ startswith”代替“包含”,但由于某种原因,它一直告诉我它是一个意外的象征。
确切的错误:(
线:33,col:3):意外符号:“包含”。位于表达式中的位置8:elseif包含(变量['build.sourcebranch'],'用户')
resources:
repositories:
- repository: WebAppComponents
ref: main
endpoint: RepoAccess
type: git
name: Project/WebAppComponents.git
- repository: test-data
ref: main
endpoint: RepoAccess
type: git
name: Project/test-data.git
variables:
- template: Variables/default.yml
- ${{ if contains(variables['resources.repositories.WebAppComponents.ref'], 'user') }}:
- template: Variables/dev.yml
- ${{ elseif contains(variables['Build.SourceBranch'], 'user') }}:
- template: Variables/dev.yml
- ${{ else }}:
- template: Variables/main.yml
I can't figure this one out. Any help is appreciated. This is driving me nuts, not sure what I am doing wrong.
I have tried replacing 'contains' with 'eq' and 'startsWith' but for some reason it keeps telling me its an unexpected symbol.
Exact error:
(Line: 33, Col: 3): Unexpected symbol: 'contains'. Located at position 8 within expression: elseif contains(variables['Build.SourceBranch'], 'user')
resources:
repositories:
- repository: WebAppComponents
ref: main
endpoint: RepoAccess
type: git
name: Project/WebAppComponents.git
- repository: test-data
ref: main
endpoint: RepoAccess
type: git
name: Project/test-data.git
variables:
- template: Variables/default.yml
- ${{ if contains(variables['resources.repositories.WebAppComponents.ref'], 'user') }}:
- template: Variables/dev.yml
- ${{ elseif contains(variables['Build.SourceBranch'], 'user') }}:
- template: Variables/dev.yml
- ${{ else }}:
- template: Variables/main.yml
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了完全相同的问题。
我不确定为什么是这种情况,但是缩进
elseif
和else
进一步的条件似乎可以解决问题。尝试一下
I came across the exact same issue.
I am not sure why this is the case, but indenting
elseif
andelse
conditions further in seems to solve the issue.Try this