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

After upgrading Jenkins, the plugin dosen't work anymore #35

Closed
eXtrem0us opened this issue Dec 23, 2022 · 20 comments
Closed

After upgrading Jenkins, the plugin dosen't work anymore #35

eXtrem0us opened this issue Dec 23, 2022 · 20 comments
Assignees
Labels

Comments

@eXtrem0us
Copy link

Jenkins and plugins versions report

Environment
Paste the output here

What Operating System are you using (both controller, and any agents involved in the problem)?

Jenkins Docker Image.
In Version 2.378, everything's fine. But after upgrading to Version 2.383, it breaks.
It has been tested on both JDK 11 and JDK 17.

Reproduction steps

Upgrade Jenkins to the latest version.

Expected Results

The message successfully send to Zulip.

Actual Results

The output of Jenkins pipeline, after running zulipSend message: 'some messages here'

java.lang.ClassNotFoundException: org.apache.commons.httpclient.Credentials
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:476)
	at jenkins.util.URLClassLoader2.findClass(URLClassLoader2.java:35)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
Caused: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/Credentials
	at jenkins.plugins.zulip.ZulipSendStep.perform(ZulipSendStep.java:44)
	at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:101)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:71)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
[Pipeline] // catchError
[Pipeline] stage
[Pipeline] { (Notify)
[Pipeline] zulipNotification
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.lang.ClassNotFoundException: org.apache.commons.httpclient.Credentials
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:476)
	at jenkins.util.URLClassLoader2.findClass(URLClassLoader2.java:35)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
Caused: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/Credentials
	at jenkins.plugins.zulip.ZulipNotifier.publish(ZulipNotifier.java:133)
	at jenkins.plugins.zulip.ZulipNotifier.perform(ZulipNotifier.java:86)
	at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:101)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:71)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Finished: FAILURE

Anything else?

No response

@eXtrem0us eXtrem0us added the bug label Dec 23, 2022
@eXtrem0us
Copy link
Author

It seems in the changelog of Jenkins the reason for this issue is mentioned:

What's new in 2.379 (2022-11-22)

Jenkins no longer bundles a patched version of the deprecated Commons HttpClient 3.x library for use by plugins.
Plugins should be migrated to the native Java 11 HTTP client or updated to depend on the legacy Commons HttpClient 3.x API plugin.

@timabbott
Copy link

@butchyyyy do you have time to investigate this?

In any case, pull requests are welcome.

@butchyyyy
Copy link
Collaborator

Thanks for reporting and apologies for the inconvenience. I'll try to come up with a quick fix this week (adding the commons HttpClient dependency).

@butchyyyy butchyyyy self-assigned this Jan 8, 2023
@xavier-calland
Copy link

FWIW I tried switch to java.net.http client which requires upgrading to java 11+. I had problems with the tests: powermock, mokito, … are not compatible.
If you want, I can share my work as WIP.

@koval-jan
Copy link

koval-jan commented Jan 12, 2023

Quick fix is to add pom dependency for plugin commons-httpclient3-api (https://plugins.jenkins.io/commons-httpclient3-api/)

<dependency>
    <groupId>io.jenkins.plugins</groupId>
    <artifactId>commons-httpclient3-api</artifactId>
    <version>3.1-3</version>
</dependency>

EvgenyKuzavlev pushed a commit to EvgenyKuzavlev/zulip-plugin that referenced this issue Feb 2, 2023
EvgenyKuzavlev pushed a commit to EvgenyKuzavlev/zulip-plugin that referenced this issue Feb 2, 2023
@EvgenyKuzavlev
Copy link

I tried add а dependency for plugin commons-httpclient3-api to pom. I builded .hpi and tested it in my jenkins server(v. 2.386) and it worked successful, BUT unit-tests were failed. I am going to try fix a problem with tests.

@jamesvl
Copy link

jamesvl commented Mar 13, 2023

This release of Jenkins just hide the wider apt repositories in Ubuntu, so I hit this bug today when I upgraded.

Is there a quick way to fix this locally? I can still in the Commons HttpClient 3.x API Plugin, but that alone doesn't appear sufficient.

@EvgenyKuzavlev
Copy link

@jamesvl You can pull my fork and execute mvn hpi:hpi for build a hpi file. After you can manually install it. See https://www.jenkins.io/doc/book/managing/plugins/ for more details.

yrodiere added a commit to hibernate/hibernate-demos that referenced this issue Apr 5, 2023
yrodiere added a commit to hibernate/hibernate-demos that referenced this issue Apr 5, 2023
yrodiere added a commit to beanvalidation/beanvalidation.org that referenced this issue Apr 5, 2023
yrodiere added a commit to hibernate/in.relation.to that referenced this issue Apr 5, 2023
yrodiere added a commit to hibernate/hibernate.org that referenced this issue Apr 5, 2023
yrodiere added a commit to hibernate/hibernate-test-case-templates that referenced this issue Apr 20, 2023
@epaul13
Copy link

epaul13 commented May 9, 2023

@EvgenyKuzavlev: I used your fork and build it with last maven without problems. After copying the zulip.hpi to plugins/zulip.jpi, the plugin is correctly loaded, but the global configuration and post-build step are not showing up. Any clue?

Note:
Maven home: /opt/apache-maven-3.9.1
Java version: 11.0.18, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.15.104-1-pve", arch: "amd64", family: "unix"

@ipikiiskinen
Copy link

@EvgenyKuzavlev
I also used your fork and build it with:

$ mvn --version Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8) Maven home: /opt/apache-maven-3.9.1 Java version: 11.0.18, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.el7_9.x86_64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-1160.88.1.el7.x86_64", arch: "amd64", family: "unix"
I got the same results as @epaul13
Plugin does not report any error in start up, gets listed as installed plugin, but it does not show in global config or in build definitions.
Tested with the latest Jenkins LTS release 2.387.3 (RedHat 7 RPM installation) and openjdk version "11.0.19" 2023-04-18 LTS

@EvgenyKuzavlev Have you managed to the get the plugin working with the latest LTS Jenkins?

@ipikiiskinen
Copy link

@butchyyyy you mentioned that you would be looking at this. Any chance to get this fixed?

@EvgenyKuzavlev
Copy link

EvgenyKuzavlev commented May 11, 2023

@ipikiiskinen @epaul13 I didn't try to use my fork with latest Jenkins, maybe it doesn't work. I am going to update Jenkins and test it later.

My env:
centos-release-7-9.2009.1.el7.centos.x86_64
openjdk 11.0.17 2022-10-18 LTS
jenkins 2.386

@epaul13
Copy link

epaul13 commented Jun 2, 2023

Any news? I can try to make a correction, but my java is rusted, and I don't know maven nor Jenkins dev env... Might not be the most efficient move :)

@butchyyyy
Copy link
Collaborator

I have started working on a new major version, it will:

  • Make the plugin compatible with LTS Jenkins version
  • Bump the minimal Jenkins version to 2.387.3
  • Bump the minimal Java version to 11
  • Migrate away from apache commons http client to java.net http client

I have bulk of the work done. I just need to adjust the unit tests and give this a proper test flight before shipping the new version. Will keep you posted.

@butchyyyy
Copy link
Collaborator

^^ The PR is up, all unit and integration tests are passing.

There are more or less no functional changes besides the http client migration. The rest is mostly formatting stuff and test migration away from Powermock.

I still need to run some manual testing against Jenkins + Zulip before I release this. If anyone has time to also give the branch a quick test and report any issues, it will be much appreciated.

Of course feel free to leave comments on the PR as well, it's first Java code I did in ~4 years 🙈

@epaul13
Copy link

epaul13 commented Jun 9, 2023

@butchyyyy

I checked out your PR and tested it. I have now access to global configuration and project post-build actions. Great work!

At first, I was unable to get any messages, with an error in Jenkins logs:

#011SEVERE#011jenkins.plugins.zulip.Zulip#post: Error sending Zulip message:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I had to add my zulip server chain certificate to make it work. On Ubuntu 22.04, it means:

sudo cp zulip.combined-chain.crt /usr/local/share/ca-certificates
sudo update-ca-certificates
sudo /var/lib/dpkg/info/ca-certificates-java.postinst configure
sudo systemctl restart jenkins

Now I get my jenkins post messages from Jenkins!
Thank you again!

So this work on Jenkins 2.387.3 on java 11.0.18 on Ubuntu 22.04


To build, for maven/jenkins devenv noobs like me:

git clone https://github.com/jenkinsci/zulip-plugin.git                                                                                                                                
cd zulip-plugin/
git checkout origin/version2
mvn package
# uninstall previous zulip plugin
sudo -u jenkins cp target/zulip.hpi /var/lib/jenkins/plugins/
sudo systemctl restart jenkins

with:

mvn --version
Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Maven home: /opt/apache-maven-3.9.1
Java version: 11.0.18, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.15.104-1-pve", arch: "amd64", family: "unix"

@butchyyyy
Copy link
Collaborator

Thanks a lot for testing it @epaul13!
The certificate chain validation is correct and afaik it was performed also with the Apache http client. Let me know if you think this is behaving differently than before.

I was also testing on my end today and verified several scenarios including proxy being setup in Jenkins both with and without authentication.

I think we are good to go, will most probably do the release tomorrow.

@butchyyyy
Copy link
Collaborator

Resolved in version 2.0.0

@epaul13
Copy link

epaul13 commented Jun 12, 2023

Thanks a lot for testing it @epaul13! The certificate chain validation is correct and afaik it was performed also with the Apache http client. Let me know if you think this is behaving differently than before.

I was also testing on my end today and verified several scenarios including proxy being setup in Jenkins both with and without authentication.

I think we are good to go, will most probably do the release tomorrow.

Good news. For the certificate validation, my bad. I tested on a brand-new container, and my old jenkins is probably ten years old. I just checked and I have the same chain on the old server. So everything' good!

@eXtrem0us
Copy link
Author

Thank You @butchyyyy ! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants