Writes a yaml file in the current working directory from an Object or a String. It uses SnakeYAML as YAML processor. The call will fail if the file already exists.
Fields:file
:
Mandatory path to a file in the workspace to write the YAML datas to.
data
:
A Mandatory Object containing the data to be serialized.
charset
(optional):
Optionally specify the charset to use when writing the file. Defaults to UTF-8
if nothing else is specified.
What charsets that are available depends on your Jenkins master system.
The java specification tells us though that at least the following should be available:
overwrite
(optional):
Allow existing files to be overwritten. Defaults to false
.
Examples:
def amap = ['something': 'my datas',
'size': 3,
'isEmpty': false]
writeYaml file: 'datas.yaml', data: amap
def read = readYaml file: 'datas.yaml'
assert read.something == 'my datas'
assert read.size == 3
assert read.isEmpty == false