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 plugin parent POM to latest version #62

Merged
merged 6 commits into from
Nov 18, 2019
Merged

Conversation

basil
Copy link
Member

@basil basil commented Nov 13, 2019

This is the first of a series of changes to get this plugin's builds and tests into decent shape as described in jenkins-infra/repository-permissions-updater#1325. After this change is merged, I plan to update the Jenkinsfile to use buildPlugin.recommendedConfigurations(). After that, I plan to clean up and improve the tests. And after that, I plan to merge the fixes for #57 and #58.

This PR implements the following:

  • Updates the plugin parent POM to the latest version.
  • Sets the POM URL to the plugin's GitHub URL, which is the current recommended best practice.
  • Sets the minimum Jenkins version to 2.60.3 and the Java level to 8, which is the lowest currently supported version of Java for Jenkins.
  • Makes workflow-cps-plugin and workflow-support-plugin versions into properties to reduce code duplication.
  • Updates the developers list in the POM.
  • Adds a dependencyManagement section to the POM. This allows us to fix the Mvaen Enforcer warnings that are encountered when upgrading to the latest plugin parent POM.
  • Replaces the non-standard edu.umd.cs.findbugs.annotations.NonNull annotation with the standard javax.annotation.Nonnull annotation. This allows us to remove the explicit com.google.code.findbugs:jsr305 dependency from the POM.
  • Converts ThrottleIntegrationTest from the deprecated HudsonTestCase to the non-deprecated JenkinsRule. This allows us to fix a test failure that is encountered when upgrading to the latest plugin parent POM and Jenkins test harness.
  • Incrementalifies the plugin.

Comment on lines +106 to +119
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.25</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.icon-shim</groupId>
<artifactId>icon-set</artifactId>
<version>2.0.3</version>
</dependency>
</dependencies>
</dependencyManagement>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the following Maven Enforcer errors after upgrading to the latest plugin parent POM:

[WARNING] Rule 4: org.apache.maven.plugins.enforcer.RequireUpperBoundDeps failed with message:
Failed while enforcing RequireUpperBoundDeps. The error(s) are [
Require upper bound dependencies error for org.jenkins-ci.plugins:script-security:1.13 paths to dependency are:
+-org.jenkins-ci.plugins:throttle-concurrents:2.0.2-SNAPSHOT
  +-org.jenkins-ci.plugins:matrix-project:1.8
    +-org.jenkins-ci.plugins:script-security:1.13
and
+-org.jenkins-ci.plugins:throttle-concurrents:2.0.2-SNAPSHOT
  +-org.jenkins-ci.plugins.workflow:workflow-durable-task-step:2.8
    +-org.jenkins-ci.plugins:script-security:1.25
and
+-org.jenkins-ci.plugins:throttle-concurrents:2.0.2-SNAPSHOT
  +-org.jenkins-ci.plugins.workflow:workflow-cps:2.28
    +-org.jenkins-ci.plugins:script-security:1.24
and
+-org.jenkins-ci.plugins:throttle-concurrents:2.0.2-SNAPSHOT
  +-org.jenkins-ci.plugins.workflow:workflow-cps:2.28
    +-org.jenkins-ci.plugins:script-security:1.24
and
+-org.jenkins-ci.plugins:throttle-concurrents:2.0.2-SNAPSHOT
  +-org.jenkins-ci.plugins.workflow:workflow-support:2.13
    +-org.jenkins-ci.plugins:script-security:1.21
and
+-org.jenkins-ci.plugins:throttle-concurrents:2.0.2-SNAPSHOT
  +-org.jenkins-ci.plugins.workflow:workflow-support:2.13
    +-org.jenkins-ci.plugins:script-security:1.21
, 
Require upper bound dependencies error for org.jenkins-ci.plugins.icon-shim:icon-set:1.0.5 paths to dependency are:
+-org.jenkins-ci.plugins:throttle-concurrents:2.0.2-SNAPSHOT
  +-org.jenkins-ci.main:jenkins-core:2.60.3
    +-org.jenkins-ci.plugins.icon-shim:icon-set:1.0.5
and
+-org.jenkins-ci.plugins:throttle-concurrents:2.0.2-SNAPSHOT
  +-org.jenkins-ci.plugins:matrix-auth:1.4
    +-org.jenkins-ci.plugins.icon-shim:icon-shim:2.0.3
      +-org.jenkins-ci.plugins.icon-shim:icon-set:2.0.3

@@ -50,39 +55,45 @@
/**
* Tests that {@link ThrottleJobProperty} actually works for builds.
*/
public class ThrottleIntegrationTest extends HudsonTestCase {
public class ThrottleIntegrationTest {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the following test failure after upgrading to the latest parent POM:

java.lang.RuntimeException: Failed to serialize jenkins.model.Jenkins#securityRealm for class hudson.model.Hudson
	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
	at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
	at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
	at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
	at hudson.XmlFile.write(XmlFile.java:171)
	at jenkins.model.Jenkins.save(Jenkins.java:3201)
	at jenkins.model.Jenkins.saveQuietly(Jenkins.java:3207)
	at jenkins.model.Jenkins.setSecurityRealm(Jenkins.java:2588)
	at hudson.plugins.throttleconcurrents.ThrottleIntegrationTest.setupSecurity(ThrottleIntegrationTest.java:95)
	at hudson.plugins.throttleconcurrents.ThrottleIntegrationTest.testThrottlingWithCategory(ThrottleIntegrationTest.java:123)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at org.jvnet.hudson.test.HudsonTestCase.runTest(HudsonTestCase.java:445)
	at junit.framework.TestCase.runBare(TestCase.java:141)
	at org.jvnet.hudson.test.HudsonTestCase.runBare(HudsonTestCase.java:279)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:129)
	at junit.framework.TestSuite.runTest(TestSuite.java:252)
	at junit.framework.TestSuite.run(TestSuite.java:247)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
Caused by: java.lang.RuntimeException: Failed to serialize org.jvnet.hudson.test.HudsonTestCase$3#this$0 for class org.jvnet.hudson.test.HudsonTestCase$3
	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
	... 43 more
Caused by: com.thoughtworks.xstream.converters.reflection.ObjectAccessException: Could not call hudson.plugins.throttleconcurrents.ThrottleIntegrationTest.writeReplace() : HudsonTestCase testThrottlingWithCategory is not supposed to be serialized
	at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteReplace(SerializationMethodInvoker.java:95)
	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:141)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
	... 52 more
Caused by: java.lang.AssertionError: HudsonTestCase testThrottlingWithCategory is not supposed to be serialized
	at org.jvnet.hudson.test.HudsonTestCase.writeReplace(HudsonTestCase.java:1370)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteReplace(SerializationMethodInvoker.java:89)
	... 58 more

@@ -26,14 +26,15 @@ THE SOFTWARE.
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.26</version>
<version>3.51</version>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.52 resulted in the following error, presumably due to jenkinsci/plugin-pom#229:

[ERROR] Failed to execute goal org.codehaus.mojo:flatten-maven-plugin:1.1.0:flatten (flatten) on project throttle-concurrents: 8 problems were encountered while building the effective model for org.jenkins-ci.plugins:throttle-concurrents:2.0.2-SNAPSHOT
[ERROR] [ERROR] 'dependencies.dependency.version' for com.github.spotbugs:spotbugs-annotations:jar is missing. @ 
[ERROR] [ERROR] 'dependencies.dependency.version' for net.jcip:jcip-annotations:jar is missing. @ 
[ERROR] [ERROR] 'dependencies.dependency.version' for org.slf4j:slf4j-api:jar is missing. @ 
[ERROR] [ERROR] 'dependencies.dependency.version' for org.slf4j:log4j-over-slf4j:jar is missing. @ 
[ERROR] [ERROR] 'dependencies.dependency.version' for org.slf4j:jcl-over-slf4j:jar is missing. @ 
[ERROR] [ERROR] 'dependencies.dependency.version' for org.slf4j:slf4j-jdk14:jar is missing. @ 
[ERROR] [ERROR] 'dependencies.dependency.version' for org.kohsuke:access-modifier-annotation:jar is missing. @ 
[ERROR] [ERROR] 'dependencies.dependency.version' for commons-logging:commons-logging:jar is missing. @ 

Downgrading to 3.51 to work around the problem for now.

@basil basil added the internal label Nov 14, 2019
@basil
Copy link
Member Author

basil commented Nov 14, 2019

From my perspective, this change is now ready to merge. @oleg-nenashev, what is your preference for how I should go about future changes to this plugin? Are you interested in reviewing each one? If so, I can wait for your review before I merge each change. If not, I can just merge them when I feel ready. Or we could do something in-between, waiting a specified amount of time for you to review (or not) after which I go ahead. What do you prefer?

@basil
Copy link
Member Author

basil commented Nov 18, 2019

Since I haven't heard back from @oleg-nenashev in the past couple of days, I'm going to go ahead and proceed with this and subsequent changes by myself. Please let me know if you want to revisit this approach.

@basil basil merged commit 4bd6f62 into jenkinsci:master Nov 18, 2019
@basil basil deleted the pom branch December 13, 2019 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant