test-kitchen:无法在Windows上的.kitchen.yml中使用ENV变量

时间:2018-05-25 20:43:36

标签: windows chef yaml erb test-kitchen

在Windows平台上使用.kitchen.yml var时,我似乎无法在ENV中使用erb。

$ kitchen list
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::UserError
>>>>>> Message: Error parsing C:/Users/anonymous/.kitchen.yml as YAML.
Please run `kitchen diagnose --no-instances --loader' to help debug your issue.
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

.kitchen.yml

---
driver:
  name: vagrant
  synced_folders:
    - [<%= ENV['PWD'] %>, '/tmp/foo']

provisioner:
  name: chef_zero

platforms:
  - name: ubuntu-16.04

suites:
  - name: default

ENV

$ chef -v
Chef Development Kit Version: 2.4.17
chef-client version: 13.6.4
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.1
kitchen version: 1.19.2
inspec version: 1.45.13

这在我的Ubuntu 16.04机器上工作正常,使用相同的文件和软件版本。

我认为这与黄瓜/阿鲁巴项目报道的类似问题有关〜https://github.com/cucumber/aruba/issues/291

我尝试向测试厨房项目提交一个新问题,但他们将我推荐给他们的contributing guidelines,这只是一个发布过程。由于我无法提交新的问题,所以我希望能够提供一些清晰度或解决方法。

1 个答案:

答案 0 :(得分:0)

问题可能是在更换Erb之后,这看起来像- [C:\Users\anonymous, '/tmp/foo']:中有一个重要的YAML语法字符。简单的解决方案是- ["<%= ENV['PWD'] %>", '/tmp/foo']- [<%= ENV['PWD'].to_json %>, '/tmp/foo'](JSON是YAML的子集)。