jenkins - 将 YAML 文本的子集复制到单独的文件中,然后在处理时出现语法错误
问题描述
我正在研究 [Jenkins 管道 - YAML - ansible] 组合。在管道中,有一个输入部分,它看起来有点像这样:
student_input = input(
message: 'Input Student details', parameters: [text(defaultValue:
'''---
student:
ID: 100
grade: 5
info:
email: abc@xyz.com
home_town: efg
marks:
math: 95
science: 92
''',
description: '',
name: 'student'
)]
)
然后,我使用readYaml 文件将此输入写入变量:“File.yml”实用程序。
在为此的实现中,使用 map.each 循环的嵌套地图来到达信息,然后到达标记部分。
Groovy 映射代码示例:
value.each { k, v ->
sh """
echo '$k: $v' >> student.yml
"""
}
使用它,我试图将info部分的整个value部分写入一个单独的 YAML 文件,稍后将与 ansible 的include_vars模块一起使用。
在运行 groovy 管道时,我在 Ansible 中遇到了以下问题:
fatal: [localhost]: FAILED! => {"failed": true, "msg": "Syntax Error while loading YAML.
The error appears to have been in 'True': line 9, column 26,
but may\nbe elsewhere in the file depending on the exact syntax problem.(could not open file to display line)"}
当我检查最终的 YAML 文件时,标记部分看起来像这样:
marks: [math:95, science:92]
这些列表元素写入文件的方式(冒号后没有空格)似乎导致错误。
请帮我解决这个问题。我错过了什么,或者做错了什么?
解决方案
推荐阅读
- java - 使用 Flash Player 加载图形时如何使用 selenium webdriver 处理图形和读取图形数据
- django-models - Django-Oscar 覆盖非抽象模型: ShippingEventQuantity
- ios - 如何在 SwiftUI 中更改导航栏标题的文本属性?
- haskell - 编写一个灵活的“字符串提取器”
- java - 如何实现队列处理器
- javascript - 如何修复窗口打开功能
- javascript - 如何在不重新渲染的情况下为函数值创建 React Context
- windows - 如何将 Matlab 的退出状态返回到 Jenkins 控制台输出?
- go - 如何将 go-cross 添加到 Yocto SDK?或者在其他机器上编译 Go for Yocto?
- odoo-12 - Odoo 12 group_no_one 无法正常工作