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

Use development version numbers #19

Merged
merged 6 commits into from
Jan 8, 2024

Conversation

MarkEWaite
Copy link

@MarkEWaite MarkEWaite commented Jan 7, 2024

Use development version numbers

Version 1.15.0 and 1.15.1 of the plugin have been released to the Jenkins update center, even though there is no tag in the repository for those releases.

Avoid user confusion by setting the version number to 1.15.2-SNAPSHOT.

When the maintainer performs mvn release:prepare release:perform, Apache Maven will prompt for a new version number and will suggest 1.15.2. The maintainer can press enter to accept the recommendation and Apache Maven will create two commits, one that sets the release to 1.15.2 and then a second that sets it to 1.15.3-SNAPSHOT.

Depend on Apache httpclient 4 plugin instead of jar file

https://plugins.jenkins.io/apache-httpcomponents-client-4-api/ avoids the plugin bundling an outdated version of the Apache httpclient library. It replaces the bundling of the jar file with a dependency on the Apache HttpComponents Client 4.x API plugin. That plugin is installed on over 96% of all Jenkins installations.

By depending on the plugin instead of the jar file, the plugin bill of materials will manage the dependency version and the plugin will use the most recent version that is installed on the Jenkins controller.

This is a common technique used by many Jenkins plugins. Refer to https://plugins.jenkins.io/apache-httpcomponents-client-4-api/dependencies/ for the list of plugins that depend on the Apache httpclient plugin.

Use bom-2.361.x to match Jenkins minimum version

The Jenkins plugin bill of materials dependency should match the Jenkins minimum version from the jenkins.version property. Refer to https://www.jenkins.io/doc/developer/tutorial-improve/use-plugin-bill-of-materials/ for more details about the plugin bill of materials.

Use most recent parent pom - 4.76

Allows compilation with Java 11, Java 17, and Java 21. Preparing for Oct 2024 when Java 11 support in Jenkins will be end of life.

Add Jenkinsfile to check plugin on ci.jenkins.io

https://www.jenkins.io/doc/developer/tutorial-improve/add-a-jenkinsfile/ describes the benefits of including a Jenkinsfile in the plugin repository. This will provide a ci.jenkins.io job that evaluates the master branch and any pull request branches automatically.

Testing done

Interactive tests confirmed that the correct plugin version is displayed to the user. Interactive tests also confirmed that the Apache httpclient library dependency was added as expected. Compilation messages no longer report that a transitive dependency on an older Apache httpclient library is being added to the hpi file.

Submitter checklist

Preview Give feedback

Additional notes

Confirmed that the contents of the plugin hpi file are further simplified so that the plugin hpi file now contains:

M    Mode     Size        Date&time         Filename
- ----------  -----  --------------------  ----------------
  drwxr-xr-x      0   7-Jan-2024 06:11:14  META-INF/
  -rw-r--r--   1215   7-Jan-2024 06:11:14  META-INF/MANIFEST.MF
  drwxr-xr-x      0   7-Jan-2024 06:11:14  WEB-INF/
  drwxr-xr-x      0   7-Jan-2024 06:11:14  WEB-INF/lib/
  drwxr-xr-x      0   7-Jan-2024 06:11:14  META-INF/maven/
  drwxr-xr-x      0   7-Jan-2024 06:11:14  META-INF/maven/org.jenkins-ci.plugins/
  drwxr-xr-x      0   7-Jan-2024 06:11:14  META-INF/maven/org.jenkins-ci.plugins/applitools-eyes/
  -rw-r--r--    549   7-Jan-2024 06:11:12  WEB-INF/licenses.xml
  -rw-r--r--  34820   7-Jan-2024 06:11:12  WEB-INF/lib/applitools-eyes.jar
  -rw-r--r--   2794   7-Jan-2024 06:11:08  META-INF/maven/org.jenkins-ci.plugins/applitools-eyes/pom.xml
  -rw-r--r--     82   7-Jan-2024 06:11:14  META-INF/maven/org.jenkins-ci.plugins/applitools-eyes/pom.properties
- ----------  -----  --------------------  ----------------
              39460                         11 files

The change removed several dependencies that were being included as transitive dependencies.

https://plugins.jenkins.io/apache-httpcomponents-client-4-api/ avoids
the plugin bundling an outdated version of the Apache httpclient library.
It replaces the bundling of the jar file with a dependency on the Apache
HttpComponents Client 4.x API plugin.  That plugin is installed on over
96% of all Jenkins installations.

By depending on the plugin instead of the jar file, the plugin bill of
materials will manage the dependency version and the plugin will use
the most recent version that is installed on the Jenkins controller.

This is a common technique used by many Jenkins plugins.  Refer to
https://plugins.jenkins.io/apache-httpcomponents-client-4-api/dependencies/
for the list of plugins that depend on the Apache httpclient plugin.
Version 1.15.0 and 1.15.1 of the plugin have been released to the
Jenkins update center, even though there is no tag in the repository
for those releases.

Avoid user confusion by setting the version number to 1.15.2-SNAPSHOT.

When the maintainer performs `mvn release:prepare release:perform`,
Apache Maven will prompt for a new version number and will suggest 1.15.2.
The maintainer can press enter to accept the recommendation and Apache
Maven will create two commits, one that sets the release to 1.15.2 and
then a second that sets it to 1.15.3-SNAPSHOT.
Allows compilation with Java 11, Java 17, and Java 21.  Preparing for
Oct 2024 when Java 11 support in Jenkins will be end of life.
https://www.jenkins.io/doc/developer/tutorial-improve/add-a-jenkinsfile/
describes the benefits of including a Jenkinsfile in the plugin
repository.  This will provide a ci.jenkins.io job that evaluates the
master branch and any pull request branches automatically.
@MarkEWaite
Copy link
Author

@itaibh if there are parts of this pull request that are unacceptable, let me know and I will be happy to remove them or happy to create a new pull request with the subset that you prefer.

@itaibh itaibh merged commit 3784aa9 into jenkinsci:master Jan 8, 2024
@itaibh
Copy link
Collaborator

itaibh commented Jan 8, 2024

@MarkEWaite I'm fine with those changes, but I need to be able to debug the plugin, and I'm not there yet. I see it loading correctly but I have a bug in the logic and I don't know how I can debug it. Where can I find more info about debugging jenkins plugins? The new docs doesn't seem to cover this and the old ones are outdated and seem irrelevant.

@MarkEWaite MarkEWaite deleted the increase-version-number branch January 8, 2024 12:45
@MarkEWaite
Copy link
Author

@MarkEWaite I'm fine with those changes, but I need to be able to debug the plugin, and I'm not there yet. I see it loading correctly but I have a bug in the logic and I don't know how I can debug it. Where can I find more info about debugging jenkins plugins? The new docs doesn't seem to cover this and the old ones are outdated and seem irrelevant.

https://www.jenkins.io/doc/developer/building/intellij/ provides guidance to configure IntelliJ for development and debugging of Jenkins core.

I use Netbeans for debugging with Jenkins plugins and Jenkins core.

I believe those are the two most commonly used development environments for Jenkins plugin maintainers.

@itaibh
Copy link
Collaborator

itaibh commented Jan 8, 2024

well, now I have a different problem: after changing Jenkins settings to allow debugging the service failed to load. I tried reverting the change but it still failed to load. I'm currently stuck without a working local Jenkins service.
Running ubuntu 22.04 I tried everything the web had to offer including asking chatGPT but nothing helped. Not even removing jenkins and re-installing it. I keep getting jenkins.service: Start request repeated too quickly.

@MarkEWaite
Copy link
Author

If you want to debug, you'll have a much better experience if you run Jenkins core from your own account rather than running Jenkins from the service that was installed with the Debian package (the ".deb" file).

@itaibh
Copy link
Collaborator

itaibh commented Jan 8, 2024

what do you mean "my own account"? account where?

@itaibh
Copy link
Collaborator

itaibh commented Jan 8, 2024

also I need to verify something in the UI, does jenkins core supports this?

@itaibh
Copy link
Collaborator

itaibh commented Jan 8, 2024

ok, I think I got what you meant. I'll try. thanks!

@MarkEWaite
Copy link
Author

also I need to verify something in the UI, does jenkins core supports this?

The Jenkins test harness includes a JenkinsRule that supports many forms of end to end testing. It includes HTMLUnit that can be used to verify specific contents of web pages and results from HTTP interactions with Jenkins.

Examples of tests that use the JenkinsRule WebClient to perform tests include:

  • Authorize project plugin
  • Embeddable build status plugin
  • Git plugin
  • Implied labels plugin

There are many others, but a search for WebClient in those plugins will find examples that may be helpful.

@itaibh
Copy link
Collaborator

itaibh commented Jan 9, 2024

@MarkEWaite I'm able to debug the plugin and fixed some env. vars. issue. But I have a problem with artifacts. It seems the archive sub-folder isn't created. What I see in the code is I get to the StandardArtifactManager class to the archive method, and the dir is /tmp/sanity-check-maven-hpi-plugin/jobs/Test/builds/16/archive but looking for this path in the filesystem only gets to /tmp/sanity-check-maven-hpi-plugin/jobs/Test/builds/16 so it fails in the workspace.copyRecursiveTo for unavailable directory. I don't understand why this directory wasn't created.

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