Skip to content

Commit

Permalink
Merge pull request #53 from andresrc/newParentPOM
Browse files Browse the repository at this point in the history
[JENKINS-33668] Adapt to new plugin parent POM and upgrade baseline to 1.580.1
  • Loading branch information
andresrc committed Mar 28, 2016
2 parents 22f0873 + 3f366da commit f231a0c
Show file tree
Hide file tree
Showing 37 changed files with 296 additions and 169 deletions.
102 changes: 3 additions & 99 deletions pom.xml
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.554.1</version>
<version>2.3</version>
</parent>

<artifactId>support-core</artifactId>
Expand Down Expand Up @@ -60,10 +60,6 @@
</developer>
</developers>

<prerequisites>
<maven>2.2.1</maven>
</prerequisites>

<scm>
<connection>scm:git:git://github.com/jenkinsci/support-core-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/support-core-plugin.git</developerConnection>
Expand All @@ -72,11 +68,8 @@
</scm>

<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<findbugs-maven-plugin.version>3.0.3</findbugs-maven-plugin.version>
<findbugs.failOnError>true</findbugs.failOnError>
<jenkins.version>1.580.1</jenkins.version>
<java.level>6</java.level>
</properties>

<repositories>
Expand All @@ -93,107 +86,18 @@
</pluginRepositories>

<dependencies>
<!-- regular dependencies -->
<dependency>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>1.3.9</version>
</dependency>
<!-- regular dependencies -->
<dependency>
<groupId>net.sf.uadetector</groupId>
<artifactId>uadetector-resources</artifactId>
<version>2013.09</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-annotations</artifactId>
<version>1.9</version>
</dependency>
<!-- plugin dependencies -->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>metrics</artifactId>
<version>3.0.0</version>
</dependency>
<!-- jenkins dependencies -->
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>(,2.1.0),(2.1.0,2.2.0),(2.2.0,)</version>
<message>Maven 2.1.0 and 2.2.0 produce incorrect GPG signatures and checksums respectively.
</message>
</requireMavenVersion>
<requireMavenVersion>
<version>(,3.0),[3.0.4,)</version>
<message>Maven 3.0 through 3.0.3 inclusive do not pass correct settings.xml to Maven Release
Plugin.
</message>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs-maven-plugin.version}</version>
<configuration>
<excludeFilterFile>src/findbugs/excludesFilter.xml</excludeFilterFile>
<failOnError>${findbugs.failOnError}</failOnError>
<xmlOutput>true</xmlOutput>
</configuration>
<executions>
<execution>
<id>run-findbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Expand Up @@ -46,7 +46,7 @@ public class DefaultSupportMetricsFilter extends SupportMetricsFilter {
/**
* Creates a new instance of the filter.
*
* @param registry
* @param registry Metric registry to use.
*/
public DefaultSupportMetricsFilter(MetricRegistry registry) {
super(registry, createMeterNamesByStatusCode(), NAME_PREFIX + "other");
Expand Down
Expand Up @@ -27,6 +27,7 @@
import com.cloudbees.jenkins.support.api.Component;
import com.cloudbees.jenkins.support.api.SupportProvider;

import com.cloudbees.jenkins.support.util.Helper;
import hudson.Extension;
import hudson.model.RootAction;
import hudson.security.ACL;
Expand Down Expand Up @@ -113,7 +114,7 @@ public List<Component> getComponents() {
}

public void doDownload(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
final Jenkins instance = Jenkins.getInstance();
final Jenkins instance = Helper.getActiveInstance();
instance.getAuthorizationStrategy().getACL(instance).checkPermission(CREATE_BUNDLE);

if (!"POST".equals(req.getMethod())) {
Expand Down
Expand Up @@ -34,6 +34,7 @@
import jenkins.model.Jenkins;
import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;
import org.jenkinsci.remoting.RoleChecker;
import org.kohsuke.args4j.Argument;

import java.io.File;
Expand Down Expand Up @@ -110,6 +111,12 @@ public OutputStream call() throws IOException {
System.err.println("Creating: " + f);
return new RemoteOutputStream(new FileOutputStream(f));
}

/** {@inheritDoc} */
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
// TODO: do we have to verify some role?
}
}

}
Expand Up @@ -58,6 +58,7 @@ public class SupportMetricsFilter implements Filter {
/**
* Creates a new instance of the filter.
*
* @param registry Metric registry to use.
* @param meterNamesByStatusCode A map, keyed by status code, of meter names that we are
* interested in.
* @param otherMetricName The name used for the catch-all meter.
Expand Down
42 changes: 35 additions & 7 deletions src/main/java/com/cloudbees/jenkins/support/SupportPlugin.java
Expand Up @@ -30,6 +30,7 @@
import com.cloudbees.jenkins.support.api.StringContent;
import com.cloudbees.jenkins.support.api.SupportProvider;
import com.cloudbees.jenkins.support.api.SupportProviderDescriptor;
import com.cloudbees.jenkins.support.util.Helper;
import com.codahale.metrics.Histogram;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down Expand Up @@ -64,6 +65,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;
import org.jenkinsci.remoting.RoleChecker;
import org.kohsuke.stapler.StaplerRequest;

import java.io.BufferedOutputStream;
Expand Down Expand Up @@ -153,7 +155,7 @@ public SupportPlugin() {
public SupportProvider getSupportProvider() {
if (supportProvider == null) {
// if this is not set, pick the first one that we can get our hands on
for (Descriptor<SupportProvider> d : Jenkins.getInstance().getDescriptorList(SupportProvider.class)) {
for (Descriptor<SupportProvider> d : Helper.getActiveInstance().getDescriptorList(SupportProvider.class)) {
if (d instanceof SupportProviderDescriptor) {
try {
supportProvider = ((SupportProviderDescriptor) (d)).newDefaultInstance();
Expand All @@ -168,9 +170,11 @@ public SupportProvider getSupportProvider() {

/**
* Working directory that the support-core plugin uses to write out files.
*
* @return the wrking directory that the support-core plugin uses to write out files.
*/
public static File getRootDirectory() {
return new File(Jenkins.getInstance().getRootDir(), SUPPORT_DIRECTORY_NAME);
return new File(Helper.getActiveInstance().getRootDir(), SUPPORT_DIRECTORY_NAME);
}


Expand All @@ -197,7 +201,13 @@ public Set<String> getExcludedComponents() {
return excludedComponents != null ? excludedComponents : Collections.<String>emptySet();
}

/** @see Component#getId */
/**
* Sets the ids of the components to be excluded.
*
* @param excludedComponents Component Ids (by default class names) to exclude.
* @see Component#getId
* @throws IOException if an error occurs while saving the configuration.
*/
public void setExcludedComponents(Set<String> excludedComponents) throws IOException {
this.excludedComponents = excludedComponents;
save();
Expand Down Expand Up @@ -230,7 +240,7 @@ public static void setLogLevel(String level) {
public static void setLogLevel(Level level) {
SupportPlugin instance = getInstance();
instance.handler.setLevel(level);
for (Node n : Jenkins.getInstance().getNodes()) {
for (Node n : Helper.getActiveInstance().getNodes()) {
Computer c = n.toComputer();
if (c == null) {
continue;
Expand All @@ -247,11 +257,11 @@ public static void setLogLevel(Level level) {
}

public static SupportPlugin getInstance() {
return Jenkins.getInstance().getPlugin(SupportPlugin.class);
return Helper.getActiveInstance().getPlugin(SupportPlugin.class);
}

public static ExtensionList<Component> getComponents() {
return Jenkins.getInstance().getExtensionList(Component.class);
return Helper.getActiveInstance().getExtensionList(Component.class);
}

public static void writeBundle(OutputStream outputStream) throws IOException {
Expand Down Expand Up @@ -525,6 +535,12 @@ public Void call() {
return null;
}

/** {@inheritDoc} */
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
// TODO: do we have to verify some role?
}

}

public static class LogFetcher implements Callable<List<LogRecord>, RuntimeException> {
Expand All @@ -534,6 +550,12 @@ public List<LogRecord> call() throws RuntimeException {
return new ArrayList<LogRecord>(LogHolder.SLAVE_LOG_HANDLER.getRecent());
}

/** {@inheritDoc} */
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
// TODO: do we have to verify some role?
}

}

public static class LogUpdater implements Callable<Void, RuntimeException> {
Expand All @@ -551,6 +573,12 @@ public Void call() throws RuntimeException {
return null;
}

/** {@inheritDoc} */
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
// TODO: do we have to verify some role?
}

}

@Extension
Expand Down Expand Up @@ -678,7 +706,7 @@ public boolean accept(File dir, String name) {
public static class GlobalConfigurationImpl extends GlobalConfiguration {

public boolean isSelectable() {
return Jenkins.getInstance().getDescriptorList(SupportProvider.class).size() > 1;
return Helper.getActiveInstance().getDescriptorList(SupportProvider.class).size() > 1;
}

public SupportProvider getSupportProvider() {
Expand Down
Expand Up @@ -6,6 +6,7 @@
import hudson.remoting.VirtualChannel;
import jenkins.model.Jenkins;
import org.apache.commons.io.IOUtils;
import org.jenkinsci.remoting.RoleChecker;

import java.io.*;
import java.util.WeakHashMap;
Expand Down Expand Up @@ -44,6 +45,12 @@ public String call() {
pw.flush();
return bos.toString();
}

/** {@inheritDoc} */
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
// TODO: do we have to verify some role?
}
}

private static String getNodeName(Node node) {
Expand Down
Expand Up @@ -24,6 +24,7 @@

package com.cloudbees.jenkins.support.api;

import com.cloudbees.jenkins.support.util.Helper;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.security.ACL;
import hudson.security.Permission;
Expand Down Expand Up @@ -85,7 +86,7 @@ public String getDisplayPermissions() {
* @return {@code true} if the current authentication can include this component in a bundle.
*/
public boolean isEnabled() {
ACL acl = Jenkins.getInstance().getAuthorizationStrategy().getRootACL();
ACL acl = Helper.getActiveInstance().getAuthorizationStrategy().getRootACL();
if (acl != null) {
Authentication authentication = Jenkins.getAuthentication();
assert authentication != null;
Expand All @@ -105,7 +106,11 @@ public boolean isSelectedByDefault() {
@NonNull
public abstract String getDisplayName();

/** By default, the {@link Class#getSimpleName} of the component implementation. */
/**
* Returns the component id.
*
* @return by default, the {@link Class#getSimpleName} of the component implementation.
*/
@NonNull public String getId() {
return getClass().getSimpleName();
}
Expand Down
Expand Up @@ -35,13 +35,19 @@
*/
public interface SupportContext {
/**
* @deprecated use {@link com.codahale.metrics.jenkins.Metrics#metricRegistry()}
* Returns the {@link MetricRegistry} for the current Jenkins.
*
* @return the {@link MetricRegistry} for the current Jenkins.
* @deprecated use {@link jenkins.metrics.api.Metrics#metricRegistry()}
*/
@Deprecated
MetricRegistry getMetricsRegistry();

/**
* @deprecated use {@link com.codahale.metrics.jenkins.Metrics#healthCheckRegistry()}
* Returns the {@link HealthCheckRegistry} for the current.
*
* @return the {@link HealthCheckRegistry} for the current.
* @deprecated use {@link jenkins.metrics.api.Metrics#healthCheckRegistry()}
*/
@Deprecated
HealthCheckRegistry getHealthCheckRegistry();
Expand Down

0 comments on commit f231a0c

Please sign in to comment.