Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add api for available backup list #3

Open
wants to merge 128 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
6f5b4ec
move thinBackup to Tools section in newer Jenkins versions
StefanSpieker Sep 13, 2021
8df2b4b
add api for available backup list
jxr98 Sep 25, 2021
c5932f9
Stop setting `pluginFirstClassLoader`
basil Nov 27, 2021
1e91a2d
JENKINS-267: add test and fix
krulls Dec 31, 2021
8d4b0a1
Merge pull request #30 from StefanSpieker/tools_location
tofuatjava Sep 10, 2022
e24fbb5
use latest plugin pom and at least jenkins 2.222.1
StefanSpieker Sep 25, 2022
489da86
minor test improvements
StefanSpieker Sep 25, 2022
35e772f
set IntelliJ files to gitignore
StefanSpieker Sep 25, 2022
1c99b1f
Merge pull request #36 from StefanSpieker/gitignore
StefanSpieker Sep 26, 2022
3d6bff4
Removed up for adoption notice
StefanSpieker Sep 26, 2022
5cc2dd2
Merge pull request #37 from jenkinsci/StefanSpieker-readme
StefanSpieker Sep 26, 2022
d6f8217
remove unnecessary if, as condition will always be true
mkemmerz Oct 1, 2022
d131b30
Spotbugs: Prevent possible nullpointer dereference in HudsonBackup
mkemmerz Oct 1, 2022
bdaa079
Spotbugs: Prevent possible nullpointer dereference in BackupSet
mkemmerz Oct 1, 2022
1bb6590
Spotbugs: Prevent possible nullpointer dereference in DirectoryCleaner
mkemmerz Oct 1, 2022
427e67d
Prevent null-case in restorePlugins
mkemmerz Oct 1, 2022
db2e19f
Spotbugs: Return restore in case of candidates being null
mkemmerz Oct 1, 2022
fa71b7d
Spotbugs: Prevent possible nullpointer dereference in HustonRestore
mkemmerz Oct 1, 2022
4827bf3
WIP: Bump plugin to Java 11
mkemmerz Sep 29, 2022
1009bc0
WIP: Bump some dependencies and cast one object
mkemmerz Oct 4, 2022
a2aa190
Build Plugin on Java 11 nodes & testcases fixes for Java 11
mkemmerz Oct 4, 2022
78eee1c
Removed unnecessary linebreaks, added bracket to if in HudsonBackup
mkemmerz Oct 13, 2022
f5d57bb
Merge remote-tracking branch 'stefan-fork/pom_update' into bump-to-ja…
mkemmerz Oct 13, 2022
00a52b8
Merge pull request #34 from StefanSpieker/pom_update
StefanSpieker Oct 15, 2022
4451324
[maven-release-plugin] prepare release thinBackup-1.11
StefanSpieker Oct 15, 2022
1799666
[maven-release-plugin] prepare for next development iteration
StefanSpieker Oct 15, 2022
285856f
Merge pull request #38 from mkemmerz/fix-spotbugs-warnings
StefanSpieker Oct 15, 2022
f810e3d
Merge branch 'master' into bump-to-java-11
StefanSpieker Oct 15, 2022
62d15b5
Update src/test/java/org/jvnet/hudson/plugins/thinbackup/backup/Backu…
mkemmerz Oct 18, 2022
1bbf42c
Update src/test/java/org/jvnet/hudson/plugins/thinbackup/backup/TestB…
mkemmerz Oct 18, 2022
c91cb6d
feat: update to jenkins lts version 2.361.2
Oct 18, 2022
060e01e
Merge pull request #32 from basil/pluginFirstClassLoader
StefanSpieker Oct 18, 2022
b05ed50
feat: integrate ionicons-api, update jenkins version and replace thin…
Oct 18, 2022
acf118c
Merge pull request #41 from kauppfbi/feature/ionicons
StefanSpieker Oct 18, 2022
0c38c1c
feat: redesign plugin index page
Oct 18, 2022
b453b28
Update src/test/java/org/jvnet/hudson/plugins/thinbackup/backup/TestB…
StefanSpieker Oct 18, 2022
4cc0e39
Update src/test/java/org/jvnet/hudson/plugins/thinbackup/backup/TestB…
StefanSpieker Oct 18, 2022
cc78525
Refine tests, removed Ignored tests
mkemmerz Oct 21, 2022
d859ae9
Merge pull request #35 from StefanSpieker/test
StefanSpieker Oct 22, 2022
b996b8e
remove pexus-utils dependency and added myself as developer
StefanSpieker Oct 22, 2022
441d9bc
Merge branch 'master' into bump-to-java-11
StefanSpieker Oct 22, 2022
18f50dd
use VERSION instead of getVersion to fix Spotbugs issue
StefanSpieker Oct 22, 2022
8e1dba8
use newer version of deprecated Jenkins.getInstance() call
StefanSpieker Oct 22, 2022
13fd4eb
use category since min jenkins version was bumped
StefanSpieker Oct 22, 2022
ad47ee3
fix: remove broken img references in page headers
Oct 22, 2022
8278a1f
Merge pull request #43 from kauppfbi/fix/remove-img-references-from-t…
StefanSpieker Oct 22, 2022
ecd5c83
docs: update images in readme with latest ui enhancements
Oct 22, 2022
afe1ca2
Merge branch 'master' into feature/ionicons
kauppfbi Oct 22, 2022
af7dc45
Merge pull request #42 from kauppfbi/feature/ionicons
StefanSpieker Oct 22, 2022
5cd667a
Merge pull request #44 from kauppfbi/feature/readme-images
StefanSpieker Oct 22, 2022
79935d4
[maven-release-plugin] prepare release thinBackup-1.12
StefanSpieker Oct 23, 2022
4ab5d08
[maven-release-plugin] prepare for next development iteration
StefanSpieker Oct 23, 2022
a6d4807
Create dependabot config
StefanSpieker Nov 1, 2022
3f17846
Bump plugin from 4.47 to 4.49
dependabot[bot] Nov 1, 2022
27b0f87
use https instead of http link to wikipedia
StefanSpieker Nov 1, 2022
9818de5
Merge pull request #46 from StefanSpieker/wikipedia
StefanSpieker Nov 1, 2022
6be6f56
Merge pull request #45 from jenkinsci/dependabot/maven/org.jenkins-ci…
StefanSpieker Nov 1, 2022
2887f24
add option to also backup config-history folder
StefanSpieker Nov 5, 2022
3803cbc
Use ionicons-api version provided by bom
NotMyFault Nov 11, 2022
c9114aa
Merge pull request #48 from NotMyFault/ionicons-bom
StefanSpieker Nov 11, 2022
03e95d2
Bump plugin from 4.49 to 4.50
dependabot[bot] Nov 14, 2022
add3035
Merge pull request #49 from jenkinsci/dependabot/maven/org.jenkins-ci…
StefanSpieker Nov 14, 2022
42bbb6c
Merge pull request #47 from jenkinsci/config-history
StefanSpieker Nov 19, 2022
230e734
[maven-release-plugin] prepare release thinBackup-1.13
StefanSpieker Nov 19, 2022
f36afc7
[maven-release-plugin] prepare for next development iteration
StefanSpieker Nov 19, 2022
85a4671
Merge pull request #39 from mkemmerz/bump-to-java-11
StefanSpieker Nov 19, 2022
c36ce37
removed unused imports and minor refactorings
StefanSpieker Nov 19, 2022
cb330b0
update documentation
StefanSpieker Nov 19, 2022
4597bf3
set better path
StefanSpieker Nov 19, 2022
213cc23
updated screenshot
StefanSpieker Nov 19, 2022
8332034
Merge pull request #51 from jenkinsci/documentation_update
StefanSpieker Nov 19, 2022
79d0a8e
Merge pull request #50 from jenkinsci/imports
StefanSpieker Nov 19, 2022
8dd6bea
started localizing backupsettings
StefanSpieker Nov 20, 2022
de68ec9
Bump bom-2.346.x from 1678.vc1feb_6a_3c0f1 to 1706.vc166d5f429f8
dependabot[bot] Nov 21, 2022
5343ca5
Bump plugin from 4.50 to 4.51
dependabot[bot] Nov 21, 2022
26ea362
Merge pull request #54 from jenkinsci/dependabot/maven/org.jenkins-ci…
StefanSpieker Nov 21, 2022
ad1c96f
Merge pull request #53 from jenkinsci/dependabot/maven/io.jenkins.too…
StefanSpieker Nov 21, 2022
bb132b2
Merge pull request #33 from Webfleet-Solutions/bugfix/JENKINS-67479
StefanSpieker Nov 24, 2022
96ac5e0
localized all main fields, except help files
StefanSpieker Nov 26, 2022
bceccee
Merge pull request #52 from jenkinsci/localization
StefanSpieker Nov 26, 2022
8eca4a2
[maven-release-plugin] prepare release thinBackup-1.14
StefanSpieker Nov 26, 2022
bee7957
[maven-release-plugin] prepare for next development iteration
StefanSpieker Nov 26, 2022
8a95d6e
use AsyncPeriodicWork from jenkins and not the customized one
StefanSpieker Nov 26, 2022
5aa6350
Bump bom-2.346.x from 1706.vc166d5f429f8 to 1723.vcb_9fee52c9fc
dependabot[bot] Nov 28, 2022
a316d3c
Merge pull request #56 from jenkinsci/dependabot/maven/io.jenkins.too…
StefanSpieker Nov 28, 2022
08fd751
Merge pull request #55 from jenkinsci/async_periodic
StefanSpieker Dec 3, 2022
a2fbd75
removed unneeded suppressions
StefanSpieker Dec 7, 2022
a55b9fa
fixed some deprecation warnings
StefanSpieker Dec 7, 2022
e059902
fixed minor spotbugs
StefanSpieker Dec 7, 2022
8d73fa1
Merge pull request #58 from jenkinsci/suppressions
StefanSpieker Dec 7, 2022
879cab3
Merge pull request #59 from jenkinsci/minor_refactoring
StefanSpieker Dec 7, 2022
f6d1a47
Merge branch 'master' into spotbugs_minor
StefanSpieker Dec 7, 2022
3582f41
Merge pull request #60 from jenkinsci/spotbugs_minor
StefanSpieker Dec 9, 2022
a7e6fa3
Bump bom-2.346.x from 1723.vcb_9fee52c9fc to 1742.vb_70478c1b_25f
dependabot[bot] Dec 12, 2022
8420dcf
Merge pull request #62 from jenkinsci/dependabot/maven/io.jenkins.too…
StefanSpieker Dec 12, 2022
1ca51e9
Bump bom-2.346.x from 1742.vb_70478c1b_25f to 1750.v0071fa_4c4a_e3
dependabot[bot] Dec 19, 2022
2315e4b
Merge pull request #64 from jenkinsci/dependabot/maven/io.jenkins.too…
StefanSpieker Dec 19, 2022
6f75034
converted two testclasses to Junit5
StefanSpieker Dec 20, 2022
2054e1d
fixed spotbugs issue
StefanSpieker Dec 20, 2022
c64f2de
Merge pull request #66 from jenkinsci/spotbugs_null
StefanSpieker Dec 20, 2022
643ac5a
Update Jenkinsfile to also run on Java 17
StefanSpieker Dec 20, 2022
0b5a420
Merge pull request #67 from jenkinsci/StefanSpieker-java17
StefanSpieker Dec 20, 2022
e5faab2
Merge pull request #65 from jenkinsci/junit5
StefanSpieker Dec 20, 2022
cde0914
replaced helper method with hamcrest and converted test to Junit5
StefanSpieker Dec 23, 2022
8778e5d
Merge pull request #68 from jenkinsci/simplified_tests
StefanSpieker Dec 23, 2022
47bf39f
added missing not null asserts
StefanSpieker Dec 23, 2022
e577c40
Merge pull request #69 from jenkinsci/assert_not_null
StefanSpieker Dec 23, 2022
6b61613
Bump bom-2.346.x from 1750.v0071fa_4c4a_e3 to 1757.vf3c66da_b_7492
dependabot[bot] Dec 26, 2022
d327281
Merge pull request #70 from jenkinsci/dependabot/maven/io.jenkins.too…
StefanSpieker Dec 26, 2022
74ce38f
converted tests to Junit5
StefanSpieker Dec 26, 2022
04721c3
Merge pull request #71 from jenkinsci/more_junit5
StefanSpieker Dec 26, 2022
1b67b12
Updated readme
StefanSpieker Dec 26, 2022
6932c96
Merge pull request #72 from jenkinsci/StefanSpieker-readme
StefanSpieker Dec 26, 2022
0566225
minor improvments around null checks
StefanSpieker Dec 26, 2022
abd43ad
Merge pull request #73 from jenkinsci/minor_improvments
StefanSpieker Dec 26, 2022
afeed1c
replace deprecated DirectoryWalker in Tests with Files.walk
StefanSpieker Dec 27, 2022
c1981d6
Merge pull request #74 from jenkinsci/directorywalker_test
StefanSpieker Dec 27, 2022
5d5b9bc
replaced DirectoryCleaner with java.nio.file
StefanSpieker Dec 28, 2022
5499ce0
improve error message
StefanSpieker Dec 28, 2022
08fc190
fix test
StefanSpieker Dec 28, 2022
d22b587
Merge pull request #75 from jenkinsci/directory_cleaner
StefanSpieker Dec 28, 2022
dd44547
[maven-release-plugin] prepare release thinBackup-1.15
StefanSpieker Dec 29, 2022
544f6f7
[maven-release-plugin] prepare for next development iteration
StefanSpieker Dec 29, 2022
d17c5a9
Bump bom-2.346.x from 1757.vf3c66da_b_7492 to 1763.v092b_8980a_f5e
dependabot[bot] Jan 2, 2023
b439d68
Merge pull request #76 from jenkinsci/dependabot/maven/io.jenkins.too…
StefanSpieker Jan 2, 2023
87859c0
Merge branch 'master' into backuplist
jxr98 Jan 18, 2023
24cdf41
add api for available backup list
jxr98 Sep 25, 2021
4d5c391
change Jenkins from 2.346.1 to 2.346.3
jxr98 Jan 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "maven" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
# Add assignees
assignees:
- "StefanSpieker"
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/target
/.settings
/.classpath
/.project
/.settings
/.classpath
/.project
/work
/.idea/
*~
# IntelliJ project files
*.iml
*.iws
*.ipr
/.idea/*
8 changes: 7 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/usr/bin/env groovy

/* `buildPlugin` step provided by: https://github.com/jenkins-infra/pipeline-library */
buildPlugin()
buildPlugin(
useContainerAgent: true,
configurations: [
[platform: 'linux', jdk: 11],
[platform: 'linux', jdk: 17],
[platform: 'windows', jdk: 11],
])
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

This plugin simply backs up the global and job specific configurations (not the archive or the workspace).

**This plugin is up for adoption.** Want to help improve this plugin?
[Click here to learn more](https://www.jenkins.io/doc/developer/plugin-governance/adopt-a-plugin/)!

## Why another backup plugin

The [Backup Plugin](https://plugins.jenkins.io/backup/) only does manual backups and
stores all data found in JENKINS\_HOME. This is sometimes not practical because of time and disk
space requirements and the fact that it can only be manually triggered. *ThinBackup*s can be
scheduled and only backs up the most vital configuration info.
scheduled and only backs up the most vital configuration info. Furthermore the Backup Plugin is unmaintained for quite a while.

## Documentation

This plugin adds another management link to "Manage Jenkins" called ThinBackup which looks like
This plugin adds another management link to "Manage Jenkins" in the Tools section in newer Jenkins versions, called ThinBackup which looks like
this:

![](images/ManagementLink.png)
Expand Down Expand Up @@ -110,6 +107,12 @@ so think carefully about it. Once you decide to backup build results, also get
backing up your build archives. Once again, be careful with this option because it could be very
**time consuming** and probably needs **a ton of disk space**!

#### Backup next build number file
If this option is enabled, the file `nextBuildNumber` will also be backed up.

#### Backup 'config-history' folder
If this option is enabled, the directory `config-history` will also be backed up. The plugin which creates this folder is the [Job Configuration History Plugin](https://plugins.jenkins.io/jobConfigHistory/).

#### Backup 'userContents'

Jenkins provides a URL where you can put common data (e.g., static HTML, Tools, etc.). You can
Expand Down Expand Up @@ -172,4 +175,4 @@ Please let us know if you have another option or feature for this plugin by ente
write us an email.

Before submitting a feature request or bug report, you can check if it has already been submitted by
searching issues in JIRA categorized under the thin-backup-plugin component.
searching issues in JIRA categorized under the thin-backup-plugin component or directly on the [plugin site](https://plugins.jenkins.io/jobConfigHistory/#issues)
Binary file modified images/ManagementLink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/restore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/thinBackup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/thinBackupSettings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 40 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.43</version>
<version>4.51</version>
</parent>

<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>thinBackup</artifactId>
<name>ThinBackup</name>
<version>1.11-SNAPSHOT</version>
<version>1.16-SNAPSHOT</version>
<packaging>hpi</packaging>

<licenses>
Expand Down Expand Up @@ -56,13 +56,18 @@
<organizationUrl>www.borland.com</organizationUrl>
<timezone>CET</timezone>
</developer>
<developer>
<id>StefanSpieker</id>
<name>Stefan Spieker</name>
<timezone>CET</timezone>
</developer>
</developers>

<scm>
<connection>scm:git:https://github.com/jenkinsci/thin-backup-plugin.git</connection>
<developerConnection>scm:git:https://[email protected]/jenkinsci/thin-backup-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/thin-backup-plugin</url>
<tag>HEAD</tag>
<tag>thinBackup-1.12</tag>
</scm>

<repositories>
Expand All @@ -78,11 +83,23 @@
</pluginRepository>
</pluginRepositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.346.x</artifactId>
<version>1763.v092b_8980a_f5e</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -95,24 +112,31 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.3.0</version>
<scope>test</scope>
<groupId>io.jenkins.plugins</groupId>
<artifactId>ionicons-api</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.pipeline-stage-view</groupId>
<artifactId>pipeline-rest-api</artifactId>
<version>2.10</version>
</dependency>
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jenkins.version>1.651.3</jenkins.version>
<java.level>8</java.level>
<!-- <jenkins-test-harness.version>2.13</jenkins-test-harness.version> -->
<jenkins.version>2.346.3</jenkins.version>
<!-- <jenkins-test-harness.version>2.13</jenkins-test-harness.version> -->
</properties>

<build>
Expand All @@ -125,14 +149,6 @@
</configuration>
</plugin>

<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<configuration>
<pluginFirstClassLoader>true</pluginFirstClassLoader>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -144,14 +160,14 @@
<goal>testCompile</goal>
</goals>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
</configuration>
</execution>
</executions>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
*/
package org.jvnet.hudson.plugins.thinbackup;

import com.cloudbees.workflow.util.ServeJson;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.model.ManagementLink;
import hudson.model.TaskListener;
import jenkins.model.Jenkins;
import jenkins.util.Timer;
import org.jvnet.hudson.plugins.thinbackup.restore.HudsonRestore;
import org.jvnet.hudson.plugins.thinbackup.utils.Utils;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
Expand All @@ -25,17 +38,6 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

import org.jvnet.hudson.plugins.thinbackup.restore.HudsonRestore;
import org.jvnet.hudson.plugins.thinbackup.utils.Utils;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import hudson.Extension;
import hudson.model.ManagementLink;
import hudson.model.TaskListener;
import jenkins.model.Jenkins;
import jenkins.util.Timer;

/**
* A backup solution for Hudson. Backs up configuration files from Hudson and its jobs.
Expand All @@ -55,7 +57,7 @@ public String getDisplayName() {

@Override
public String getIconFileName() {
return "package.png";
return "symbol-archive-outline plugin-ionicons-api";
}

@Override
Expand All @@ -71,7 +73,7 @@ public String getDescription() {
public void doBackupManual(final StaplerRequest res, final StaplerResponse rsp) throws IOException {
LOGGER.info("Starting manual backup.");

final Jenkins jenkins = Jenkins.getInstance();
final Jenkins jenkins = Jenkins.getInstanceOrNull();
if (jenkins == null) {
return;
}
Expand All @@ -94,7 +96,7 @@ public void doRestore(final StaplerRequest res, final StaplerResponse rsp,
@QueryParameter("restorePlugins") final String restorePlugins) throws IOException {
LOGGER.info("Starting restore operation.");

final Jenkins jenkins = Jenkins.getInstance();
final Jenkins jenkins = Jenkins.getInstanceOrNull();
if (jenkins == null) {
return;
}
Expand Down Expand Up @@ -140,8 +142,9 @@ public void doSaveSettings(final StaplerRequest res, final StaplerResponse rsp,
@QueryParameter("backupAdditionalFiles") final boolean backupAdditionalFiles,
@QueryParameter("backupAdditionalFilesRegex") final String backupAdditionalFilesRegex,
@QueryParameter("waitForIdle") final boolean waitForIdle,
@QueryParameter("backupConfigHistory") final boolean backupConfigHistory,
@QueryParameter("forceQuietModeTimeout") final String forceQuietModeTimeout) throws IOException {
Jenkins jenkins = Jenkins.getInstance();
Jenkins jenkins = Jenkins.getInstanceOrNull();
if (jenkins == null) {
return;
}
Expand All @@ -159,6 +162,7 @@ public void doSaveSettings(final StaplerRequest res, final StaplerResponse rsp,
plugin.setBackupBuildArchive(backupBuildArchive);
plugin.setBackupBuildsToKeepOnly(backupBuildsToKeepOnly);
plugin.setBackupUserContents(backupUserContents);
plugin.setBackupConfigHistory(backupConfigHistory);
plugin.setBackupNextBuildNumber(backupNextBuildNumber);
plugin.setBackupPluginArchives(backupPluginArchives);
plugin.setBackupAdditionalFiles(backupAdditionalFiles);
Expand All @@ -179,4 +183,23 @@ public List<String> getAvailableBackups() {
return Utils.getBackupsAsDates(new File(plugin.getExpandedBackupPath()));
}


@ServeJson
public List<String> doAvailableBackups() {
return getAvailableBackups();
}

/**
* Name of the category for this management link. Exists so that plugins with core dependency pre-dating the version
* when this was introduced can define a category.
* <p>
*
* @return name of the desired category, one of the enum values of Category, e.g. {@code STATUS}.
* @since 2.226
*/
@NonNull
public Category getCategory() {
return Category.TOOLS;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import hudson.model.AsyncPeriodicWork;
import org.apache.commons.lang.StringUtils;
import org.jvnet.hudson.plugins.thinbackup.backup.HudsonBackup;
import org.jvnet.hudson.plugins.thinbackup.hudson.model.AsyncPeriodicWork;

import org.jvnet.hudson.plugins.thinbackup.utils.Utils;

import antlr.ANTLRException;
Expand Down Expand Up @@ -68,7 +69,7 @@ protected void execute(final TaskListener arg0) {
}

protected void backupNow(final BackupType type) {
final Jenkins jenkins = Jenkins.getInstance();
final Jenkins jenkins = Jenkins.getInstanceOrNull();
if (jenkins == null) {
return;
}
Expand All @@ -83,7 +84,7 @@ protected void backupNow(final BackupType type) {
LOGGER.fine("Wait until executors are idle to perform backup.");
Utils.waitUntilIdleAndSwitchToQuietMode(plugin.getForceQuietModeTimeout(), TimeUnit.MINUTES);
} else {
LOGGER.warning("Do not wait until jenkins/hudson is idle to perform backup. This could cause corrupt backups.");
LOGGER.warning("Do not wait until Jenkins is idle to perform backup. This could cause corrupt backups.");
}

new HudsonBackup(plugin, type).backup();
Expand All @@ -93,14 +94,14 @@ protected void backupNow(final BackupType type) {
} catch (final IOException e) {
final String msg = MessageFormat
.format(
"Cannot perform a backup. Please be sure jenkins/hudson has write privileges in the configured backup path ''{0}''.",
"Cannot perform a backup. Please be sure Jenkins has write privileges in the configured backup path ''{0}''.",
backupPath);
LOGGER.log(Level.SEVERE, msg, e);
} finally {
if (!inQuietModeBeforeBackup) {
jenkins.doCancelQuietDown();
} else {
LOGGER.info("Backup process finished, but still in quiet mode as before. The quiet mode needs to be canceled manually, because it is not clear who is putting jenkins/hudson into quiet mode.");
LOGGER.info("Backup process finished, but still in quiet mode as before. The quiet mode needs to be canceled manually, because it is not clear who is putting Jenkins into quiet mode.");
}
}
}
Expand Down
Loading