mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-29 04:25:23 +00:00
Merge branch 'master' into feature/add-deprecated-plugin-monitor
This commit is contained in:
1591 files changed
+27244
-10917
No files matched your search
@@ -84,6 +84,7 @@ import static hudson.PluginWrapper.PluginDisableStatus.ERROR_DISABLING;
|
||||
import static hudson.PluginWrapper.PluginDisableStatus.NOT_DISABLED_DEPENDANTS;
|
||||
import static hudson.PluginWrapper.PluginDisableStatus.NO_SUCH_PLUGIN;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import jenkins.plugins.DetachedPluginsUtil;
|
||||
import static org.apache.commons.io.FilenameUtils.getBaseName;
|
||||
|
||||
/**
|
||||
@@ -230,7 +231,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link setDependents}.
|
||||
* @deprecated Please use {@link #setDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setDependants(@Nonnull Set<String> dependents) {
|
||||
@@ -246,7 +247,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link setOptionalDependents}.
|
||||
* @deprecated Please use {@link #setOptionalDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setOptionalDependants(@Nonnull Set<String> optionalDependents) {
|
||||
@@ -267,7 +268,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link getDependents}.
|
||||
* @deprecated Please use {@link #getDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public @Nonnull Set<String> getDependants() {
|
||||
@@ -276,7 +277,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
|
||||
/**
|
||||
* Like {@link #getDependents} but excluding optional dependencies.
|
||||
* @since TODO
|
||||
* @since 2.181
|
||||
*/
|
||||
public @Nonnull Set<String> getMandatoryDependents() {
|
||||
Set<String> s = new HashSet<>(dependents);
|
||||
@@ -292,7 +293,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link getOptionalDependents}.
|
||||
* @deprecated Please use {@link #getOptionalDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public @Nonnull Set<String> getOptionalDependants() {
|
||||
@@ -311,7 +312,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
|
||||
/**
|
||||
* Like {@link #hasDependents} but excluding optional dependencies.
|
||||
* @since TODO
|
||||
* @since 2.181
|
||||
*/
|
||||
public boolean hasMandatoryDependents() {
|
||||
if (isBundled) {
|
||||
@@ -321,7 +322,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link hasDependents}.
|
||||
* @deprecated Please use {@link #hasDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasDependants() {
|
||||
@@ -338,7 +339,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link hasOptionalDependents}.
|
||||
* @deprecated Please use {@link #hasOptionalDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasOptionalDependants() {
|
||||
@@ -356,7 +357,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
|
||||
/**
|
||||
* Like {@link #hasDependencies} but omitting optional dependencies.
|
||||
* @since TODO
|
||||
* @since 2.181
|
||||
*/
|
||||
public boolean hasMandatoryDependencies() {
|
||||
return dependencies.stream().anyMatch(d -> !d.optional);
|
||||
@@ -394,6 +395,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
String osgiProperty = osgiProperties[i].trim();
|
||||
if (osgiProperty.equalsIgnoreCase("resolution:=optional")) {
|
||||
isOptional = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.optional = isOptional;
|
||||
@@ -447,7 +449,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
}
|
||||
|
||||
public Api getApi() {
|
||||
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
|
||||
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
|
||||
return new Api(this);
|
||||
}
|
||||
|
||||
@@ -495,7 +497,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
|
||||
/**
|
||||
* Like {@link #getDependencies} but omits optional dependencies.
|
||||
* @since TODO
|
||||
* @since 2.181
|
||||
*/
|
||||
public List<Dependency> getMandatoryDependencies() {
|
||||
return dependencies.stream().filter(d -> !d.optional).collect(Collectors.toList());
|
||||
@@ -530,20 +532,30 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
*/
|
||||
@Exported
|
||||
public String getUrl() {
|
||||
// first look for the manifest entry. This is new in maven-hpi-plugin 1.30
|
||||
// first look in update center metadata
|
||||
List<UpdateSite.Plugin> siteMetadataList = getInfoFromAllSites();
|
||||
String firstSiteUrl = null;
|
||||
if (!siteMetadataList.isEmpty()) {
|
||||
firstSiteUrl = siteMetadataList.get(0).wiki;
|
||||
if (allUrlsMatch(firstSiteUrl, siteMetadataList)) {
|
||||
return firstSiteUrl;
|
||||
}
|
||||
}
|
||||
|
||||
// if update sites give different / empty results,
|
||||
// use manifest (since maven-hpi-plugin 1.30)
|
||||
String url = manifest.getMainAttributes().getValue("Url");
|
||||
if(url!=null) return url;
|
||||
|
||||
// fallback to update center metadata
|
||||
UpdateSite.Plugin ui = getInfo();
|
||||
if(ui!=null) return ui.wiki;
|
||||
|
||||
return null;
|
||||
if (url != null) {
|
||||
return url;
|
||||
}
|
||||
return firstSiteUrl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
private boolean allUrlsMatch(String url, List<UpdateSite.Plugin> uiList) {
|
||||
return uiList.stream().allMatch(k -> k.wiki != null && k.wiki.equals(url));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Plugin:" + getShortName();
|
||||
}
|
||||
@@ -604,12 +616,12 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
|
||||
/**
|
||||
* Returns the minimum Java version of this plugin, as specified in the plugin metadata.
|
||||
* Generally coming from the <code>java.level</code> extracted as MANIFEST's metadata with
|
||||
* Generally coming from the {@code java.level} extracted as MANIFEST's metadata with
|
||||
* <a href="https://github.com/jenkinsci/plugin-pom/pull/134">this addition on the plugins' parent pom</a>.
|
||||
*
|
||||
* @see <a href="https://github.com/jenkinsci/maven-hpi-plugin/pull/75">maven-hpi-plugin#PR-75</a>.
|
||||
*
|
||||
* @since TODO
|
||||
* @since 2.158
|
||||
*/
|
||||
@Exported
|
||||
public @CheckForNull String getMinimumJavaVersion() {
|
||||
@@ -965,7 +977,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
* the user may have installed a plugin locally developed.
|
||||
*/
|
||||
public UpdateSite.Plugin getUpdateInfo() {
|
||||
UpdateCenter uc = Jenkins.getInstance().getUpdateCenter();
|
||||
UpdateCenter uc = Jenkins.get().getUpdateCenter();
|
||||
UpdateSite.Plugin p = uc.getPlugin(getShortName(), getVersionNumber());
|
||||
if(p!=null && p.isNewerThan(getVersion())) return p;
|
||||
return null;
|
||||
@@ -975,12 +987,17 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
* returns the {@link hudson.model.UpdateSite.Plugin} object, or null.
|
||||
*/
|
||||
public UpdateSite.Plugin getInfo() {
|
||||
UpdateCenter uc = Jenkins.getInstance().getUpdateCenter();
|
||||
UpdateCenter uc = Jenkins.get().getUpdateCenter();
|
||||
UpdateSite.Plugin p = uc.getPlugin(getShortName(), getVersionNumber());
|
||||
if (p != null) return p;
|
||||
return uc.getPlugin(getShortName());
|
||||
}
|
||||
|
||||
private List<UpdateSite.Plugin> getInfoFromAllSites() {
|
||||
UpdateCenter uc = Jenkins.get().getUpdateCenter();
|
||||
return uc.getPluginFromAllSites(getShortName(), getVersionNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this plugin has update in the update center.
|
||||
*
|
||||
@@ -1009,6 +1026,15 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
return !archive.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link DetachedPluginsUtil#isDetachedPlugin}.
|
||||
* @since 2.185
|
||||
*/
|
||||
@Exported
|
||||
public boolean isDetached() {
|
||||
return DetachedPluginsUtil.isDetachedPlugin(shortName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by short name.
|
||||
*/
|
||||
@@ -1028,7 +1054,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
* Where is the backup file?
|
||||
*/
|
||||
public File getBackupFile() {
|
||||
return new File(Jenkins.getInstance().getRootDir(),"plugins/"+getShortName() + ".bak");
|
||||
return new File(Jenkins.get().getRootDir(),"plugins/"+getShortName() + ".bak");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1204,14 +1230,14 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
//
|
||||
@RequirePOST
|
||||
public HttpResponse doMakeEnabled() throws IOException {
|
||||
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
|
||||
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
|
||||
enable();
|
||||
return HttpResponses.ok();
|
||||
}
|
||||
|
||||
@RequirePOST
|
||||
public HttpResponse doMakeDisabled() throws IOException {
|
||||
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
|
||||
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
|
||||
disable();
|
||||
return HttpResponses.ok();
|
||||
}
|
||||
@@ -1219,7 +1245,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
@RequirePOST
|
||||
@Deprecated
|
||||
public HttpResponse doPin() throws IOException {
|
||||
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
|
||||
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
|
||||
// See https://groups.google.com/d/msg/jenkinsci-dev/kRobm-cxFw8/6V66uhibAwAJ
|
||||
LOGGER.log(WARNING, "Call to pin plugin has been ignored. Plugin name: " + shortName);
|
||||
return HttpResponses.ok();
|
||||
@@ -1228,7 +1254,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
@RequirePOST
|
||||
@Deprecated
|
||||
public HttpResponse doUnpin() throws IOException {
|
||||
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
|
||||
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
|
||||
// See https://groups.google.com/d/msg/jenkinsci-dev/kRobm-cxFw8/6V66uhibAwAJ
|
||||
LOGGER.log(WARNING, "Call to unpin plugin has been ignored. Plugin name: " + shortName);
|
||||
return HttpResponses.ok();
|
||||
@@ -1236,7 +1262,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
|
||||
@RequirePOST
|
||||
public HttpResponse doDoUninstall() throws IOException {
|
||||
Jenkins jenkins = Jenkins.getActiveInstance();
|
||||
Jenkins jenkins = Jenkins.get();
|
||||
|
||||
jenkins.checkPermission(Jenkins.ADMINISTER);
|
||||
archive.delete();
|
||||
|
||||
Reference in new issue
Block a user