Skip to content

Commit

Permalink
Modernize plugin for June 2023 (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Jun 22, 2023
1 parent 345ea92 commit 75ab309
Show file tree
Hide file tree
Showing 30 changed files with 115 additions and 120 deletions.
24 changes: 8 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.64</version>
<version>4.67</version>
<relativePath />
</parent>

Expand All @@ -18,8 +18,8 @@
<properties>
<changelist>999999-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<jenkins.version>2.361.4</jenkins.version>
<findbugs.effort>Max</findbugs.effort>
<jenkins.version>2.375.3</jenkins.version>
<spotbugs.effort>Max</spotbugs.effort>
<hpi.compatibleSinceVersion>4.0</hpi.compatibleSinceVersion>
</properties>

Expand Down Expand Up @@ -68,8 +68,8 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.361.x</artifactId>
<version>2102.v854b_fec19c92</version>
<artifactId>bom-2.375.x</artifactId>
<version>2179.v0884e842b_859</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand All @@ -80,7 +80,7 @@
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>3.12</version>
<version>3.22</version>
<optional>true</optional>
<exclusions>
<exclusion>
Expand Down Expand Up @@ -138,7 +138,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>job-dsl</artifactId>
<version>1.74</version>
<version>1.82</version>
<optional>true</optional>
<exclusions>
<exclusion>
Expand All @@ -160,21 +160,13 @@
<!-- TODO: it is something insane, no? -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>parameterized-trigger</artifactId>
<version>2.33</version>
<version>2.45</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-auth</artifactId>
<scope>test</scope>
<exclusions>
<!-- Real Upper Bounds dependency issue,
See the discussion in https://github.com/jenkinsci/plugin-pom/pull/72 -->
<exclusion>
<groupId>org.jenkins-ci.plugins.icon-shim</groupId>
<artifactId>icon-set</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import hudson.model.JobPropertyDescriptor;
import hudson.model.listeners.ItemListener;
import hudson.util.IOUtils;
import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import jenkins.model.Jenkins;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.export.Exported;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.HttpResponses;
import org.kohsuke.stapler.QueryParameter;
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/hudson/plugins/promoted_builds/Promotion.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.HttpResponses;
Expand Down Expand Up @@ -98,7 +98,7 @@ public AbstractBuild<?,?> getTargetBuild() {
* @return Target build
* @throws IllegalStateException There is no target build
*/
@Nonnull
@NonNull
public AbstractBuild<?,?> getTargetBuildOrFail() {
final AbstractBuild<?, ?> target = getTargetBuild();
if (target == null) {
Expand Down Expand Up @@ -191,7 +191,7 @@ public EnvVars getEnvironment(TaskListener listener) throws IOException, Interru
* The method tries various sources like {@link UserIdCause} or {@link ManualCondition.Badge}.
* @return user's name who triggered the promotion, or 'anonymous' if the search fails
*/
@Nonnull
@NonNull
public String getUserName() {
// Deprecated, but we still want to support it in order to maintain the compatiibility
final UserCause userCause = getCause(UserCause.class);
Expand Down Expand Up @@ -227,7 +227,7 @@ public String getUserName() {
* If the search fails, returns ID of {@link User#getUnknown()}.
* @since 2.22
*/
@Nonnull
@NonNull
public String getUserId() {
// Deprecated, but we still want to support it in order to maintain the compatibility
// We try to convert the cause to the user ID by using a search by the full name, not reliable
Expand Down Expand Up @@ -286,7 +286,7 @@ public List<ParameterValue> getParameterValues(){
* @return List of parameter definitions to be presented.
* May be empty if there is no {@link ManualCondition}.
*/
@Nonnull
@NonNull
public List<ParameterDefinition> getParameterDefinitionsWithValue(){
List<ParameterDefinition> definitions=new ArrayList<ParameterDefinition>();
ManualCondition manualCondition=(ManualCondition) getProject().getPromotionCondition(ManualCondition.class.getName());
Expand Down Expand Up @@ -539,8 +539,8 @@ public static ParametersAction getParametersActions(Promotion build){
* @deprecated Use {@link PromotionParametersAction} with constructor instead.
*/
@Deprecated
public static void buildParametersAction(@Nonnull List<Action> actions,
@Nonnull AbstractBuild<?, ?> build,
public static void buildParametersAction(@NonNull List<Action> actions,
@NonNull AbstractBuild<?, ?> build,
@CheckForNull List<ParameterValue> promotionParams) {
// Create list of actions to pass to scheduled build
actions.add(PromotionParametersAction.buildFor(build, promotionParams));
Expand Down Expand Up @@ -577,7 +577,7 @@ private List<ParameterValue> filter(List<ParameterValue> params) {
}

public static PromotionParametersAction buildFor(
@Nonnull AbstractBuild<?, ?> buildToBePromoted,
@NonNull AbstractBuild<?, ?> buildToBePromoted,
@CheckForNull List<ParameterValue> promotionParams) {
if (promotionParams == null) {
promotionParams = new ArrayList<ParameterValue>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.util.ArrayList;
import java.util.List;
import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import jenkins.model.Jenkins;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import hudson.model.AbstractProject;
import hudson.plugins.promoted_builds.conditions.ManualCondition;
import hudson.security.AccessDeniedException2;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.model.Jenkins;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
Expand All @@ -40,14 +40,14 @@
@Restricted(NoExternalUse.class)
public class PromotionPermissionHelper {

public static void checkPermission(@Nonnull AbstractProject<?,?> target, @CheckForNull ManualCondition associatedCondition) {
public static void checkPermission(@NonNull AbstractProject<?,?> target, @CheckForNull ManualCondition associatedCondition) {
if (!hasPermission(target, associatedCondition)) {
// TODO: Give a more accurate error message if the user has Promotion.PROMOTE but is not in the list of approvers.
throw new AccessDeniedException2(Jenkins.getAuthentication(), Promotion.PROMOTE);
}
}

public static boolean hasPermission(@Nonnull AbstractProject<?,?> target, @CheckForNull ManualCondition associatedCondition) {
public static boolean hasPermission(@NonNull AbstractProject<?,?> target, @CheckForNull ManualCondition associatedCondition) {
if (associatedCondition == null) {
return target.hasPermission(Promotion.PROMOTE);
} else if (associatedCondition.getUsersAsSet().isEmpty()) {
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/hudson/plugins/promoted_builds/PromotionProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;

/**
* A dummy {@link AbstractProject} to carry out promotion operations.
Expand Down Expand Up @@ -337,7 +337,7 @@ private static EnvVars getDefaultParameterValuesAsEnvVars(AbstractProject owner)
* we return the gold icon for compatibility with previous releases
* @return the icon file name for this promotion
*/
@Nonnull
@NonNull
private static String getIcon(@CheckForNull String sIcon) {
if ((sIcon == null) || sIcon.equals(""))
return "star-gold";
Expand All @@ -350,7 +350,7 @@ private static String getIcon(@CheckForNull String sIcon) {
* @param build The build to be checked
* @return List of generated promotion badges
*/
@Nonnull
@NonNull
public List<PromotionBadge> getMetQualifications(AbstractBuild<?,?> build) {
List<PromotionBadge> badges = new ArrayList<PromotionBadge>();
for (PromotionCondition cond : conditions) {
Expand All @@ -367,7 +367,7 @@ public List<PromotionBadge> getMetQualifications(AbstractBuild<?,?> build) {
* @param build Build to be checked
* @return List of unmet promotion conditions
*/
@Nonnull
@NonNull
public List<PromotionCondition> getUnmetConditions(AbstractBuild<?,?> build) {
List<PromotionCondition> unmetConditions = new ArrayList<PromotionCondition>();

Expand Down Expand Up @@ -514,7 +514,7 @@ public boolean scheduleBuild() {
return super.scheduleBuild();
}

public boolean scheduleBuild(@Nonnull AbstractBuild<?,?> build) {
public boolean scheduleBuild(@NonNull AbstractBuild<?,?> build) {
return scheduleBuild(build,new UserCause());
}

Expand All @@ -526,7 +526,7 @@ public boolean scheduleBuild(@Nonnull AbstractBuild<?,?> build) {
* Use {@link #scheduleBuild2(AbstractBuild, Cause)}
*/
@Deprecated
public boolean scheduleBuild(@Nonnull AbstractBuild<?,?> build, @Nonnull Cause cause) {
public boolean scheduleBuild(@NonNull AbstractBuild<?,?> build, @NonNull Cause cause) {
return scheduleBuild2(build,cause)!=null;
}

Expand All @@ -538,7 +538,7 @@ public boolean scheduleBuild(@Nonnull AbstractBuild<?,?> build, @Nonnull Cause c
* @return Future result or {@code null} if the promotion cannot be scheduled
*/
@CheckForNull
public Future<Promotion> scheduleBuild2(@Nonnull AbstractBuild<?,?> build,
public Future<Promotion> scheduleBuild2(@NonNull AbstractBuild<?,?> build,
Cause cause, @CheckForNull List<ParameterValue> params) {
List<Action> actions = new ArrayList<Action>();
actions.add(Promotion.PromotionParametersAction.buildFor(build, params));
Expand All @@ -554,11 +554,11 @@ public void doBuild(StaplerRequest req, StaplerResponse rsp, @QueryParameter Tim
throw HttpResponses.error(404, "Promotion processes may not be built directly");
}

public Future<Promotion> scheduleBuild2(@Nonnull AbstractBuild<?,?> build, @Nonnull Cause cause) {
public Future<Promotion> scheduleBuild2(@NonNull AbstractBuild<?,?> build, @NonNull Cause cause) {
return scheduleBuild2(build, cause, null);
}

public boolean isInQueue(@Nonnull AbstractBuild<?,?> build) {
public boolean isInQueue(@NonNull AbstractBuild<?,?> build) {
for (Item item : Jenkins.get().getQueue().getItems(this))
if (item.getAction(PromotionTargetAction.class).resolve(this)==build)
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import hudson.model.InvisibleAction;
import jenkins.model.Jenkins;

import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;

/**
* Remembers what build it's promoting. Attached to {@link Promotion}.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/hudson/plugins/promoted_builds/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import java.util.List;
import java.util.concurrent.Future;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
Expand Down Expand Up @@ -119,7 +119,7 @@ public PromotionProcess getProcess() {
* @param size size of the icon, will be used in the icon path
* @return Path to the icon in resources
*/
@Nonnull
@NonNull
public String getIcon(String size) {
String baseName;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package hudson.plugins.promoted_builds.conditions;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import hudson.EnvVars;
import hudson.Extension;
import hudson.Util;
Expand Down Expand Up @@ -36,11 +34,12 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.Stack;

import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import org.kohsuke.stapler.export.Exported;

Expand Down Expand Up @@ -216,11 +215,11 @@ public PromotionCondition newInstance(StaplerRequest req, JSONObject formData) t
public AutoCompletionCandidates doAutoCompleteJobs(@QueryParameter String value, @AncestorInPath AbstractProject project) {
List<AbstractProject> downstreams = project.getDownstreamProjects();
List<Item> all = Jenkins.get().getItems(Item.class);
List<String> candidatesDownstreams = Lists.newArrayList();
List<String> candidatesOthers = Lists.newArrayList();
List<String> candidatesDownstreams = new ArrayList<>();
List<String> candidatesOthers = new ArrayList<>();
for (Item i : all) {
if(! i.hasPermission(Item.READ)) continue;
Set<String> names = Sets.newLinkedHashSet();
Set<String> names = new LinkedHashSet<>();
names.add(i.getRelativeNameFrom(project));
names.add(i.getFullName());
for(String name : names) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedUsageException;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import java.util.List;
import java.util.Set;
import java.util.concurrent.Future;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;

import javax.servlet.ServletException;

Expand Down Expand Up @@ -251,7 +251,7 @@ public Badge(List<ParameterValue> values) {
* @return User name or {@link #MISSING_USER_ID_DISPLAY_STRING} if the user cannot be determined
*/
@Exported
@Nonnull
@NonNull
public String getUserName() {
if (authenticationName == null)
return MISSING_USER_ID_DISPLAY_STRING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import javaposse.jobdsl.plugin.DslEnvironment;

import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import static javaposse.jobdsl.plugin.ContextExtensionPoint.executeInContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.List;
import java.util.Map;

import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import org.apache.commons.lang.ObjectUtils;

Expand Down
Loading

0 comments on commit 75ab309

Please sign in to comment.