You can use Jenkins Configuration as Code (JCasC) to manage files managed by the Config File Provider plugin. For plugin version 3.4.1 and up, you can define global configuration files under the unclassified.globalConfigFiles.configs key in your YAML configuration.
Supported file types include custom, json, xml, and mavenSettings. Each entry requires an id, name, and content. Specific types like mavenSettings support additional fields such as isReplaceAll and serverCredentialMappings.
unclassified:
globalConfigFiles:
configs:
- custom:
id: custom-test
name: DummyCustom1
comment: dummy custom 1
content: dummy content 1
- json:
id: json-test
name: DummyJsonConfig
comment: dummy json config
content: |
{ "dummydata": {"dummyKey": "dummyValue"} }
- xml:
id: xml-test
name: DummyXmlConfig
comment: dummy xml config
content: <root><dummy test="abc"></dummy></root>
- mavenSettings:
id: maven-test
name: DummySettings
comment: dummy settings
isReplaceAll: false
serverCredentialMappings:
- serverId: server1
credentialsId: someCredentials1
- serverId: server2
credentialsId: someCredentials2
content: |
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
</settings>