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

Update Jenkins Core requirement to 2.138.3, use jenkinsci/bom as a source of dependency versions #80

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 23 additions & 22 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.5</version>
<version>3.49</version>
</parent>

<groupId>com.synopsys.jenkinsci</groupId>
<artifactId>ownership</artifactId>
<version>0.12.2-SNAPSHOT</version>
<version>0.13.0-SNAPSHOT</version>
<name>Job and Node ownership plugin</name>
<packaging>hpi</packaging>
<description>Provides explicit ownership of jobs and nodes</description>
Expand All @@ -23,11 +23,11 @@
</licenses>

<properties>
<jenkins.version>1.651.3</jenkins.version>
<java.level>7</java.level>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<workflow.version>1.14</workflow.version>
<jenkins.version>2.138.4</jenkins.version>
<java.level>8</java.level>
<findbugs.effort>Max</findbugs.effort>
<!-- Uses restricted Security Inspector API -->
<useBeta>true</useBeta>
</properties>

<developers>
Expand All @@ -47,7 +47,19 @@
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
<tag>HEAD</tag>
</scm>


<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom</artifactId>
<version>2.138.2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -58,25 +70,22 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>token-macro</artifactId>
<version>1.6</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.synopsys.arc.jenkinsci.plugins</groupId>
<artifactId>job-restrictions</artifactId>
<version>0.1</version>
<version>0.8</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.20</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cloudbees-folder</artifactId>
<version>6.1.0</version>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -88,60 +97,52 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>security-inspector</artifactId>
<version>0.4</version>
<version>0.5</version>
<optional>true</optional>
</dependency>
<!--Plugins decoupled from the core. Would be great to make these deps optional.-->
<!--TODO: Plugins decoupled from the core. Would be great to make these deps optional.-->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-auth</artifactId>
<version>1.7</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>mailer</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>apache-httpcomponents-client-4-api</artifactId>
<version>4.5.3-2.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>${workflow.version}</version>
</dependency>

<!-- Test framework -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>${workflow.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency> <!--Implicitly required by folders-->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>2.1.13</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,17 @@
import javax.servlet.ServletException;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.jenkinsci.plugins.ownership.config.OwnershipGlobalConfiguration;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

/**
* Contains global actions and configurations.
* @since 0.0.1
* @author Oleg Nenashev
* @deprecated Code has been moved to {@link OwnershipGlobalConfiguration}
*/
@Deprecated
public class OwnershipPlugin extends Plugin {

public static final String LOG_PREFIX="[OwnershipPlugin] - ";
Expand All @@ -68,18 +71,7 @@ public class OwnershipPlugin extends Plugin {
public static final Permission MANAGE_ITEMS_OWNERSHIP = new Permission(PERMISSIONS, "Jobs", Messages._OwnershipPlugin_ManagePermissions_JobDescription(), Permission.CONFIGURE, PermissionScope.ITEM);
public static final Permission MANAGE_SLAVES_OWNERSHIP = new Permission(PERMISSIONS, "Nodes", Messages._OwnershipPlugin_ManagePermissions_SlaveDescription(), Permission.CONFIGURE, PermissionScope.COMPUTER);

private boolean requiresConfigureRights;

/**
* @deprecated Replaced by {@link ItemOwnershipPolicy}
*/
@Deprecated
private transient boolean assignOnCreate;
private final List<OwnershipAction> pluginActions = new ArrayList<>();
public String mailResolverClassName;
private ItemSpecificSecurity defaultJobsSecurity;
private OwnershipPluginConfiguration configuration;


/**
* @deprecated Use {@link #getInstance()} instead
*/
Expand All @@ -88,41 +80,25 @@ public class OwnershipPlugin extends Plugin {
public static OwnershipPlugin Instance() {
return getInstance();
}


/**
* Get the plugin instance.
* @return Plugin instance
* @throws IllegalStateException Jenkins instance or the plugin have not been initialized yet
*/
@Nonnull
public static OwnershipPlugin getInstance() {
Jenkins j = Jenkins.getInstance();
OwnershipPlugin plugin = j != null ? j.getPlugin(OwnershipPlugin.class) : null;
Jenkins j = Jenkins.get();
OwnershipPlugin plugin = j.getPlugin(OwnershipPlugin.class);
if (plugin == null) { // Fail horribly
// TODO: throw a graceful error
throw new IllegalStateException("Cannot get the plugin's instance. Jenkins or the plugin have not been initialized yet");
throw new IllegalStateException("Cannot get the plugin's instance. The plugin have not been initialized yet");
}
return plugin;
}

@Override
public void start() throws Exception {
load();
reinitActionsList();
Jenkins.getActiveInstance().getActions().addAll(pluginActions);
}

@Override
protected void load() throws IOException {
super.load();

// Migration to 1.5.0: Check ItemOwnershipPolicy
if (configuration == null) {

ItemOwnershipPolicy itemOwnershipPolicy = (assignOnCreate)
? new AssignCreatorPolicy() : new DropOwnershipPolicy();
configuration = new OwnershipPluginConfiguration(itemOwnershipPolicy);

save();
}
}

public boolean isRequiresConfigureRights() {
return requiresConfigureRights;
return OwnershipGlobalConfiguration.get().isRequiresConfigureRights();
}

/**
Expand All @@ -136,12 +112,14 @@ public boolean isAssignOnCreate() {
}

@CheckForNull
@Deprecated
public ItemSpecificSecurity getDefaultJobsSecurity() {
return defaultJobsSecurity;
return OwnershipGlobalConfiguration.get().getDefaultJobsSecurity();
}


@Deprecated
public OwnershipPluginConfiguration getConfiguration() {
return configuration;
return OwnershipGlobalConfiguration.get().getConfiguration();
}

/**
Expand All @@ -154,15 +132,8 @@ public ItemSpecificSecurity.ItemSpecificDescriptor getItemSpecificDescriptor() {
return ItemSpecificSecurity.DESCRIPTOR;
}

/**
* {@link OwnershipPlugin} initialization for test suites.
* @param requiresConfigureRights
* @param mailResolverClassName
* @param defaultJobsSecurity
* @param configuration
* @throws IOException
*/
public void configure(boolean requiresConfigureRights, String mailResolverClassName,
/*
public void configure(boolean requiresConfigureRights, String mailResolverClassName,
ItemSpecificSecurity defaultJobsSecurity,
OwnershipPluginConfiguration configuration) throws IOException {
this.requiresConfigureRights = requiresConfigureRights;
Expand All @@ -174,7 +145,7 @@ public void configure(boolean requiresConfigureRights, String mailResolverClassN
save();
Jenkins.getActiveInstance().getActions().addAll(pluginActions);
}

/*
@Override
public void configure(StaplerRequest req, JSONObject formData)
throws IOException, ServletException, Descriptor.FormException {
Expand All @@ -194,54 +165,30 @@ public void configure(StaplerRequest req, JSONObject formData)
if (formData.containsKey("defaultJobsSecurity")) {
this.defaultJobsSecurity = getItemSpecificDescriptor().newInstance(req, formData.getJSONObject("defaultJobsSecurity"));
}

reinitActionsList();
save();
Jenkins.getActiveInstance().getActions().addAll(pluginActions);
}

private void reinitActionsList() {
pluginActions.clear();
}

*/

//TODO: clarify the default value
@Nonnull
public static String getDefaultOwner() {
User current = User.current();
return current != null ? current.getId() : "";
}


@Deprecated
public boolean hasMailResolverRestriction() {
return mailResolverClassName != null;
return getMailResolverClassName() != null;
}

@CheckForNull
@Deprecated
public String getMailResolverClassName() {
return mailResolverClassName;
return OwnershipGlobalConfiguration.get().getMailResolverClassName();
}

/**
* Gets the configured {@link OwnershipLayoutFormatterProvider}.
* @since 0.5
* @return Ownership Layout Formatter to be used
*/
@Deprecated
public @Nonnull OwnershipLayoutFormatterProvider getOwnershipLayoutFormatterProvider() {
//TODO: replace by the extension point
return OwnershipLayoutFormatterProvider.DEFAULT_PROVIDER;
}

public FormValidation doCheckUser(@QueryParameter String userId) {
userId = Util.fixEmptyAndTrim(userId);
if (userId == null) {
return FormValidation.error("Field is empty. Field will be ignored");
}

User usr = User.getById(userId, false);
if (usr == null) {
return FormValidation.warning("User " + userId + " is not registered in Jenkins");
}

return FormValidation.ok();
return OwnershipGlobalConfiguration.get().getOwnershipLayoutFormatterProvider();
}

/**
Expand All @@ -252,7 +199,8 @@ public FormValidation doCheckUser(@QueryParameter String userId) {
@CheckForNull
public String resolveEmail(User user) {
try {
if (hasMailResolverRestriction()) {
String mailResolverClassName = getMailResolverClassName();
if (mailResolverClassName != null) {
if (mailResolverClassName.equals(FAST_RESOLVER_ID)) {
return MailAddressResolver.resolveFast(user);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import javax.annotation.Nonnull;

import hudson.security.Permission;
import org.jenkinsci.plugins.ownership.config.OwnershipGlobalConfiguration;
import org.jenkinsci.plugins.ownership.model.OwnershipHelperLocator;
import org.jenkinsci.plugins.ownership.model.OwnershipInfo;
import org.jenkinsci.plugins.ownership.model.jobs.JobOwnershipDescriptionSource;
Expand Down Expand Up @@ -177,7 +178,7 @@ public static void setProjectSpecificSecurity(@Nonnull Job<?, ?> job,

@Override
public @Nonnull Collection<User> getPossibleOwners(@Nonnull Job<?, ?> item) {
if (OwnershipPlugin.getInstance().isRequiresConfigureRights()) {
if (OwnershipGlobalConfiguration.get().isRequiresConfigureRights()) {
IUserFilter filter = new AccessRightsFilter(item, Job.CONFIGURE);
return UserCollectionFilter.filterUsers(User.getAll(), true, filter);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

import net.sf.json.JSONObject;

import org.jenkinsci.plugins.ownership.config.OwnershipGlobalConfiguration;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.HttpResponses;
import org.kohsuke.stapler.StaplerRequest;
Expand Down Expand Up @@ -99,7 +100,7 @@ public ItemSpecificSecurity getItemSpecificSecurity() {

@CheckForNull
private static ItemSpecificSecurity getGlobalItemSpecificSecurity() {
return OwnershipPlugin.getInstance().getDefaultJobsSecurity();
return OwnershipGlobalConfiguration.get().getDefaultJobsSecurity();
}

/**
Expand Down Expand Up @@ -154,7 +155,7 @@ public HttpResponse doProjectSpecificSecuritySubmit(StaplerRequest req, StaplerR
public HttpResponse doRestoreDefaultSpecificSecuritySubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, Descriptor.FormException {
getDescribedItem().checkPermission(OwnershipPlugin.MANAGE_ITEMS_OWNERSHIP);
// Get default security
ItemSpecificSecurity defaultJobsSecurity = OwnershipPlugin.getInstance().getDefaultJobsSecurity();
ItemSpecificSecurity defaultJobsSecurity = OwnershipGlobalConfiguration.get().getDefaultJobsSecurity();
ItemSpecificSecurity val = defaultJobsSecurity != null ? defaultJobsSecurity.clone() : null;

JobOwnerHelper.setProjectSpecificSecurity(getDescribedItem(), val);
Expand Down
Loading