Skip to content

Document exporting configuration from a groovy script #2557

@its-dave

Description

@its-dave

What feature do you want to see added?

There are use cases for being able to export the JCasC config programmatically (for instance identifying changes that have been made in the Jenkins UI), however the docs do not mention how to do so (whereas the reload docs do). There are also other issues (#1373 and #2175) requesting this functionality.

It appears to be possible to export the config from a groovy script using this code:

import io.jenkins.plugins.casc.ConfigurationAsCode
def stream = new ByteArrayOutputStream()
ConfigurationAsCode.get().export(stream)
stream.toString()

The export method is annotated with @Restricted(NoExternalUse.class) which implies this is not intended to be available, however the process appears to work without issue.

Is there any reason not to officially document this process?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions