Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-63719

add returnText option to writeYaml

XMLWordPrintable

      Currently the writeYaml step is only able to output the yaml to a file. However, sometimes we need the resulting yaml as a string in Groovy, such as when building a kubernetes pod spec. The only workaround is either to write to some temp file and then call readYaml, or to directly call into SnakeYaml, neither of which is ideal.

      I propose adding a boolean returnText parameter to writeYaml. If it is omitted or false, then writeYaml preserves its existing behavior. If it is true, then file and ovewrite must not be specified and writeYaml will return the yaml as a string.

      Example usage:

      String yaml = writeYaml data: object, returnText: true

       

            rsandell rsandell
            rittneje Jesse Rittner
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: