-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Jenkins installed via Helm chart:
chart version: 5.1.3
jenkins version: 2.440.2
plugin configuration added via helmsman to augment values.yaml:
installPlugins:
# plugins provided by the helm chart, although with possible version updates
- 'configuration-as-code:1775.v810dc950b_514'
- 'git:5.2.1'
- 'kubernetes:4203.v1dd44f5b_1cf9'
- 'workflow-aggregator:596.v8c21c963d92d'
# plugins indirectly provided by the helm chart, with version updates
- 'sshd:3.322.v159e91f6a_550'
- 'subversion:2.17.3'
additionalPlugins:
- 'ansible:307.va_1f3ef06575a_'
- 'conditional-buildstep:1.4.3'
- 'email-ext:2.105'
- 'git-parameter:0.9.19'
- 'golang:1.4'
- 'htmlpublisher:1.33'
- 'junit:1259.v65ffcef24a_88'
- 'last-changes:2.7.11'
- 'parameterized-scheduler:262.v00f3d90585cc'
- 'parameterized-trigger:787.v665fcf2a_830b_'
- 'semantic-versioning-plugin:1.15'
- 'thinBackup:1.19'
- 'timestamper:1.26'
Since thinBackup doesn't support JCasC, I also added a Groovy script to prepare an XML config file for it (the "/var/jenkins_backup" location mentioned below is a persistent volume I added to jenkins):
initScripts:
thin-backup-plugin-config: |
def xml = """<?xml version='1.1' encoding='UTF-8'?>
|<org.jvnet.hudson.plugins.thinbackup.ThinBackupPluginImpl plugin="thinBackup@1.19">
| <fullBackupSchedule>H 5 * * *</fullBackupSchedule>
| <diffBackupSchedule></diffBackupSchedule>
| <backupPath>/var/jenkins_backup</backupPath>
| <nrMaxStoredFull>3</nrMaxStoredFull>
| <excludedFilesRegex></excludedFilesRegex>
| <waitForIdle>true</waitForIdle>
| <forceQuietModeTimeout>120</forceQuietModeTimeout>
| <cleanupDiff>false</cleanupDiff>
| <moveOldBackupsToZipFile>false</moveOldBackupsToZipFile>
| <backupBuildResults>true</backupBuildResults>
| <backupBuildArchive>false</backupBuildArchive>
| <backupPluginArchives>false</backupPluginArchives>
| <backupUserContents>false</backupUserContents>
| <backupConfigHistory>false</backupConfigHistory>
| <backupAdditionalFiles>false</backupAdditionalFiles>
| <backupAdditionalFilesRegex></backupAdditionalFilesRegex>
| <backupNextBuildNumber>false</backupNextBuildNumber>
| <backupBuildsToKeepOnly>false</backupBuildsToKeepOnly>
| <failFast>true</failFast>
|</org.jvnet.hudson.plugins.thinbackup.ThinBackupPluginImpl>""".stripMargin()
def home = System.getenv("JENKINS_HOME")
def config = "thinBackup.xml"
def file = new File(home + File.separator + config)
file << xml
Jenkins installed via Helm chart: chart version: 5.1.3 jenkins version: 2.440.2 plugin configuration added via helmsman to augment values.yaml: installPlugins: # plugins provided by the helm chart, although with possible version updates - 'configuration-as-code:1775.v810dc950b_514' - 'git:5.2.1' - 'kubernetes:4203.v1dd44f5b_1cf9' - 'workflow-aggregator:596.v8c21c963d92d' # plugins indirectly provided by the helm chart, with version updates - 'sshd:3.322.v159e91f6a_550' - 'subversion:2.17.3' additionalPlugins: - 'ansible:307.va_1f3ef06575a_' - 'conditional-buildstep:1.4.3' - 'email-ext:2.105' - 'git-parameter:0.9.19' - 'golang:1.4' - 'htmlpublisher:1.33' - 'junit:1259.v65ffcef24a_88' - 'last-changes:2.7.11' - 'parameterized-scheduler:262.v00f3d90585cc' - 'parameterized-trigger:787.v665fcf2a_830b_' - 'semantic-versioning-plugin:1.15' - 'thinBackup:1.19' - 'timestamper:1.26' Since thinBackup doesn't support JCasC, I also added a Groovy script to prepare an XML config file for it (the "/var/jenkins_backup" location mentioned below is a persistent volume I added to jenkins): initScripts: thin-backup-plugin-config: | def xml = """<?xml version='1.1' encoding='UTF-8'?> |<org.jvnet.hudson.plugins.thinbackup.ThinBackupPluginImpl plugin=" thinBackup@1.19 "> | <fullBackupSchedule>H 5 * * *</fullBackupSchedule> | <diffBackupSchedule></diffBackupSchedule> | <backupPath>/var/jenkins_backup</backupPath> | <nrMaxStoredFull>3</nrMaxStoredFull> | <excludedFilesRegex></excludedFilesRegex> | <waitForIdle>true</waitForIdle> | <forceQuietModeTimeout>120</forceQuietModeTimeout> | <cleanupDiff>false</cleanupDiff> | <moveOldBackupsToZipFile>false</moveOldBackupsToZipFile> | <backupBuildResults>true</backupBuildResults> | <backupBuildArchive>false</backupBuildArchive> | <backupPluginArchives>false</backupPluginArchives> | <backupUserContents>false</backupUserContents> | <backupConfigHistory>false</backupConfigHistory> | <backupAdditionalFiles>false</backupAdditionalFiles> | <backupAdditionalFilesRegex></backupAdditionalFilesRegex> | <backupNextBuildNumber>false</backupNextBuildNumber> | <backupBuildsToKeepOnly>false</backupBuildsToKeepOnly> | <failFast>true</failFast> |</org.jvnet.hudson.plugins.thinbackup.ThinBackupPluginImpl>""".stripMargin() def home = System.getenv("JENKINS_HOME") def config = "thinBackup.xml" def file = new File(home + File.separator + config) file << xml
The environment info above provides both versions of things, and configurations of things. I'll summarize what I ran into here.
- If I use a Groovy init script to provide a thinBackup.xml file in /var/jenkins_home it isn't used by the plugin. The desired settings do not appear when navigating to the "ThinBackup" section of "Manage Jenkins". The file was correctly created by the Groovy script, but the changes are not found in the UI. I tried using "Reload Configuration From Disk" within "Manage Jenkins", but nothing changed. I tried using the Script Console and running "jenkins.model.Jenkins.getInstance().reload()" but yet again, nothing changed.
- Just in case I missed some subtle mistake in the config file I had crafted, I tried removing it, initialling ThinBackup manually to trigger it to create thinBackup.xml. Then I manually changed one setting in the file (I altered "/var/jenkins_backup" to "/var/jenkins_backup2"). Attempts to reload the configuration from disk, once again, did not work.
- I have verified that the plugin does indeed function. I can manually configure it, and manually trigger backups to the desired backup location.
- If I install some entirely unrelated plugin and set Jenkins to restart once the plugin is available, THEN AND ONLY THEN can I navigate to the ThinBackup settings and see the changes applied from disk.
As far as I can tell, the only opportunity to use automation to initialize the ThinBackup plugin with a desired configuration is before Jenkins starts. Once Jenkins has started, no joy.
For anybody that wants to do the same kind of thing with a helm-based install, I was able to figure out a workaround that did not entail hacking any of the existing template files, nor creating a custom container image.
mountPath: '/var/jenkins_home/thinBackup.xml'subPath: 'thinBackup.xml'
All of this presumes you have already done something to create a backup destination to give the path for in the configuration. In my case, that was a PVC/PV combo also added to the helm chart's templates directory, and that volume is also mounted via persistence.volumes and persistence.mounts information.
The end result was that I was able to see a backup happen after a fresh install, without ever logging in, due only to the cron schedule and backup destination info that had been supplied in the ConfigMap.