我想在我的剧本中使用 Azure DevOps 预定义变量“ $(Build.SourcesDirectory) ”:
这是我的剧本:
---
- hosts: KBR_MTL361
tasks:
- name: copy file
win_copy:
src: D:\Web.config
dest: $(Build.SourcesDirectory)
我正在使用 Azure DevOps Pipeline 运行这个 ansible-playbook:
TFS Pipeline Task
但它不起作用
有没有人知道如何在管道中使用变量?
最佳答案
只需在 中添加您的变量作为附加参数azure-pipelines.yml 像这样:
- task: Ansible@0
inputs:
ansibleInterface: 'agentMachine'
playbookPathOnAgentMachine: 'ansible/tfs_playbooks/install_agent.yml'
inventoriesAgentMachine: 'file'
inventoryFileOnAgentMachine: 'hosts.yml'
args: '--extra-vars "build_source_dir=$(Build.SourcesDirectory) AGENT_URL=$(AGENT_URL)"'
然后你可以访问你的 中的变量剧本 :
---
- hosts: localhost
tasks:
- name: show debug
debug:
msg: "Dir {{ build_source_dir }} agent url {{AGENT_URL}}"
关于powershell - 如何在我的 Ansible Playbook 中使用 Azure DevOps 服务器 (TFS) 预定义变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59768155/