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

Remove Jenkins test harness from hpi file #18

Merged
merged 1 commit into from
Jan 7, 2024

Conversation

MarkEWaite
Copy link

Remove Jenkins test harness HTMLUnit from the plugin hpi file

jenkinsci/jenkins#8714 included in Jenkins 2.434 and later will refuse to load a plugin that includes the Jenkins test harness.

The Jenkins test harness causes unexpected failures when it is included in a Jenkins plugin. Refer to the following issue reports for examples:

The additional benefit of the change is that it makes the plugin hpi file over 80% smaller.

Before this change, the plugin hpi file had the following contents:

  1136 META-INF/MANIFEST.MF
    73 META-INF/maven/org.jenkins-ci.plugins/applitools-eyes/pom.properties
  3153 META-INF/maven/org.jenkins-ci.plugins/applitools-eyes/pom.xml
 34814 WEB-INF/lib/applitools-eyes.jar
353793 WEB-INF/lib/commons-codec-1.15.jar
588337 WEB-INF/lib/commons-collections-3.2.2.jar
327135 WEB-INF/lib/commons-io-2.11.0.jar
434678 WEB-INF/lib/commons-lang3-3.4.jar
380196 WEB-INF/lib/cssparser-0.9.16.jar
767140 WEB-INF/lib/httpclient-4.5.6.jar
326356 WEB-INF/lib/httpcore-4.4.10.jar
4079701 WEB-INF/lib/jenkins-test-harness-htmlunit-2.18-1.jar
108240 WEB-INF/lib/jetty-io-9.2.12.v20150709.jar
357855 WEB-INF/lib/jetty-util-9.2.12.v20150709.jar
125315 WEB-INF/lib/nekohtml-1.9.22.jar
 15808 WEB-INF/lib/sac-1.3.jar
276420 WEB-INF/lib/serializer-2.7.2.jar
 43776 WEB-INF/lib/websocket-api-9.2.12.v20150709.jar
 36264 WEB-INF/lib/websocket-client-9.2.12.v20150709.jar
179845 WEB-INF/lib/websocket-common-9.2.12.v20150709.jar
3154938 WEB-INF/lib/xalan-2.7.2.jar
1367760 WEB-INF/lib/xercesImpl-2.11.0.jar
220536 WEB-INF/lib/xml-apis-1.4.01.jar
 10963 WEB-INF/licenses.xml

After this change, the plugin hpi file has the following contents:

  1136 META-INF/MANIFEST.MF
    73 META-INF/maven/org.jenkins-ci.plugins/applitools-eyes/pom.properties
  2951 META-INF/maven/org.jenkins-ci.plugins/applitools-eyes/pom.xml
 34479 WEB-INF/lib/applitools-eyes.jar
353793 WEB-INF/lib/commons-codec-1.15.jar
767140 WEB-INF/lib/httpclient-4.5.6.jar
326356 WEB-INF/lib/httpcore-4.4.10.jar
  1814 WEB-INF/licenses.xml

Testing done

Confirmed that compilation, test, and packaging of the plugin behaves as expected.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes

jenkinsci/jenkins#8714 included in Jenkins 2.434
and later will refuse to load a plugin that includes the Jenkins test
harness.

The Jenkins test harness causes unexpected failures when it is included
in a Jenkins plugin.  Refer to the following issue reports for examples:

* https://issues.jenkins.io/browse/JENKINS-65650
* https://issues.jenkins.io/browse/JENKINS-66060
* https://issues.jenkins.io/browse/JENKINS-72353

The additional benefit of the change is that it makes the plugin hpi
file over 80% smaller.

Before this change, the plugin hpi file had the following contents:

  1136 META-INF/MANIFEST.MF
    73 META-INF/maven/org.jenkins-ci.plugins/applitools-eyes/pom.properties
  3153 META-INF/maven/org.jenkins-ci.plugins/applitools-eyes/pom.xml
 34814 WEB-INF/lib/applitools-eyes.jar
353793 WEB-INF/lib/commons-codec-1.15.jar
588337 WEB-INF/lib/commons-collections-3.2.2.jar
327135 WEB-INF/lib/commons-io-2.11.0.jar
434678 WEB-INF/lib/commons-lang3-3.4.jar
380196 WEB-INF/lib/cssparser-0.9.16.jar
767140 WEB-INF/lib/httpclient-4.5.6.jar
326356 WEB-INF/lib/httpcore-4.4.10.jar
4079701 WEB-INF/lib/jenkins-test-harness-htmlunit-2.18-1.jar
108240 WEB-INF/lib/jetty-io-9.2.12.v20150709.jar
357855 WEB-INF/lib/jetty-util-9.2.12.v20150709.jar
125315 WEB-INF/lib/nekohtml-1.9.22.jar
 15808 WEB-INF/lib/sac-1.3.jar
276420 WEB-INF/lib/serializer-2.7.2.jar
 43776 WEB-INF/lib/websocket-api-9.2.12.v20150709.jar
 36264 WEB-INF/lib/websocket-client-9.2.12.v20150709.jar
179845 WEB-INF/lib/websocket-common-9.2.12.v20150709.jar
3154938 WEB-INF/lib/xalan-2.7.2.jar
1367760 WEB-INF/lib/xercesImpl-2.11.0.jar
220536 WEB-INF/lib/xml-apis-1.4.01.jar
 10963 WEB-INF/licenses.xml

After this change, the plugin hpi file has the following contents:

  1136 META-INF/MANIFEST.MF
    73 META-INF/maven/org.jenkins-ci.plugins/applitools-eyes/pom.properties
  2951 META-INF/maven/org.jenkins-ci.plugins/applitools-eyes/pom.xml
 34479 WEB-INF/lib/applitools-eyes.jar
353793 WEB-INF/lib/commons-codec-1.15.jar
767140 WEB-INF/lib/httpclient-4.5.6.jar
326356 WEB-INF/lib/httpcore-4.4.10.jar
  1814 WEB-INF/licenses.xml
@MarkEWaite MarkEWaite changed the title Remove Jenkins test harness HTMLUnit from the plugin hpi file Remove Jenkins test harness from hpi file Dec 18, 2023
@MarkEWaite
Copy link
Author

MarkEWaite commented Jan 5, 2024

@itaibh, @IdosApplitools, @danielputerman, and @nikita-andreev this plugin will no longer load into Jenkins versions 2.434 and later. It needs a new release with the changes in this pull request.

@itaibh itaibh merged commit e73ad5d into jenkinsci:master Jan 7, 2024
@itaibh
Copy link
Collaborator

itaibh commented Jan 7, 2024

@MarkEWaite thank you, but I now get this when trying to load it locally on Jenkins 2.439:

java.lang.IllegalStateException: Refusing to load the Jenkins test harness in production (via applitools-eyes)
	at hudson.ClassicPluginStrategy.createClassLoader(ClassicPluginStrategy.java:282)
	at hudson.ClassicPluginStrategy.createPluginWrapper(ClassicPluginStrategy.java:238)
	at hudson.PluginManager.dynamicLoad(PluginManager.java:928)
	at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:2249)
Caused: java.io.IOException: Failed to dynamically deploy this plugin
	at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:2253)
	at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1899)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:121)
	at java.base/java.lang.Thread.run(Thread.java:829)

@MarkEWaite MarkEWaite deleted the remove-test-harness-from-hpi branch January 7, 2024 11:49
@itaibh
Copy link
Collaborator

itaibh commented Jan 7, 2024

@MarkEWaite Ok, my bad. I had to delete the target folder and rebuild. It loads now.

@MarkEWaite
Copy link
Author

MarkEWaite commented Jan 7, 2024

I don't see the problem that you see. Here are the steps that I took to try to duplicate the problem that you are seeing:

  1. Create a file plugins.txt with the list of plugins to install and their version numbers
apache-httpcomponents-client-4-api:4.5.14-208.v438351942757
applitools-eyes:1.15.1
bouncycastle-api:2.30.1.77-225.v26ea_c9455fd9
caffeine-api:3.1.8-133.v17b_1ff2e0599
gson-api:2.10.1-15.v0d99f670e0a_7
instance-identity:185.v303dc7c645f9
ionicons-api:56.v1b_1c8c49374e
javax-activation-api:1.2.0-6
javax-mail-api:1.6.2-9
mina-sshd-api-common:2.11.0-86.v836f585d47fa_
mina-sshd-api-core:2.11.0-86.v836f585d47fa_
scm-api:683.vb_16722fb_b_80b_
script-security:1310.vf24a_dfce068b_
sshd:3.312.v1c601b_c83b_0e
structs:325.vcb_307d2a_2782
trilead-api:2.133.vfb_8a_7b_9c5dd1
workflow-api:1283.v99c10937efcb_
workflow-job:1385.vb_58b_86ea_fff1
workflow-step-api:639.v6eca_cd8c04a_a_
workflow-support:865.v43e78cc44e0d
  1. Create a file run-jenkins.sh that downloads Jenkins 2.439 and the plugins in plugins.txt
#!/bin/bash

# Applitools eyes plugin bundles Jenkins test harness
#
# https://github.com/jenkinsci/applitools-eyes-plugin/pull/18

JENKINS_WAR_VERSION=2.439
JENKINS_WAR=jenkins-${JENKINS_WAR_VERSION}.war
PLUGIN_MANAGER_VERSION=2.12.14
PLUGIN_MANAGER_JAR=jenkins-plugin-manager-${PLUGIN_MANAGER_VERSION}.jar

if [ ! -f ../$PLUGIN_MANAGER_JAR ]; then
  wget https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/${PLUGIN_MANAGER_VERSION}/$PLUGIN_MANAGER_JAR
  mv $PLUGIN_MANAGER_JAR ..
fi
if [ ! -d plugins ]; then
  mkdir plugins
fi
java -jar ../$PLUGIN_MANAGER_JAR --jenkins-version $JENKINS_WAR_VERSION --latest false --plugin-download-directory plugins --plugin-file plugins.txt

if [ ! -f ../$JENKINS_WAR ]; then
  wget https://get.jenkins.io/war/${JENKINS_WAR_VERSION}/jenkins.war
  mv jenkins.war ../$JENKINS_WAR
fi

JENKINS_HOME=. java -jar ../$JENKINS_WAR
  1. Run the run-jenkins.sh script with bash run-jenkins.sh and confirm that it reports the message:
java.lang.IllegalStateException: Refusing to load the Jenkins test harness in production (via applitools-eyes)
        at hudson.ClassicPluginStrategy.createClassLoader(ClassicPluginStrategy.java:282)
        at hudson.ClassicPluginStrategy.createPluginWrapper(ClassicPluginStrategy.java:238)
        at hudson.PluginManager$1$3$1.run(PluginManager.java:442)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:177)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:305)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1170)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:221)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:120)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)
  1. Complete the setup wizard by creating a user account and choosing to install no additional plugins
  2. Compile the applitools-eyes plugin from the master branch and copy the target/applitools-eyes.hpi file into the plugins directory as applitools-eyes.jpi
  3. Restart the running Jenkins controller by appending "/restart" to the end of the Jenkins controller URL in the browser
  4. Confirm that the applitools-eyes plugin is listed in the plugin manager and that there is no error message in the Jenkins console output

There is one surprise in that process for me. The applitools-eyes plugin version in the Jenkins plugin manager is shown as 1.14.1 even though there is a newer release of the plugin available from the Jenkins update center. I assume that means you released 1.15.0 and 1.15.1 but something went wrong and you were unable to push the release tags or the release commits to the repository. I'll submit a pull request to help you avoid that problem for future releases.

@MarkEWaite
Copy link
Author

@MarkEWaite Ok, my bad. I had to delete the target folder and rebuild. It loads now.

That's great news. Thanks.

Further improvements are included in:

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

Successfully merging this pull request may close these issues.

2 participants