jervis
jervis copied to clipboard
Preserve credentials on multibranch pipeline jobs
Multibranch pipelines overwrite their own configuration. If the configuration exists, then we want to preserve some specific values. For example, credentials or other configurations.
Here's an example of getting existing credentials and converting it to XML as plain text.
import hudson.util.DescribableList
import hudson.util.XStream2
import jenkins.model.Jenkins
XStream2 xs = new XStream2()
xs.alias('properties', DescribableList.class)
xs.toXML(Jenkins.instance.getItemByFullName('samrocketman/jervis').properties)