jenkinsci / jenkinsci/configuration-as-code-plugin
Document exporting configuration from a groovy script
- Dominant language
- Java
- Stars
- 2.8k
- Forks
- 756
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 10
Description
### 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](https://github.com/jenkinsci/configuration-as-code-plugin/blob/master/docs/features/configExport.md) do not mention how to do so (whereas the [reload docs](https://github.com/jenkinsci/configuration-as-code-plugin/blob/master/docs/features/configurationReload.md) 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](https://github.com/jenkinsci/configuration-as-code-plugin/issues/1373#issuecomment-651748386):
```
import io.jenkins.plugins.casc.ConfigurationAsCode
def stream = new ByteArrayOutputStream()
ConfigurationAsCode.get().export(stream)
stream.toString()
```
The [export method](https://github.com/jenkinsci/configuration-as-code-plugin/blob/master/plugin/src/main/java/io/jenkins/plugins/casc/ConfigurationAsCode.java#L545) 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?
Contributor guide
Assessment
This issue has not been assessed yet.