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

Add parameter to change archive repository URL and check Jenkins version against archive repositories #759

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

xT10r
Copy link

@xT10r xT10r commented Jan 9, 2025

Description

This PR introduces the ability to set a custom URL for the Jenkins plugin archive repository and adds a flag --archive to check if the selected Jenkins version corresponds to archived repositories. If the version is found in the archive, the tool will use the update center from the archive repository; otherwise, it will use the default update center URL.

The functionality is implemented through:

  1. A new command-line option --jenkins-archive-repo-mirror and the corresponding environment variable JENKINS_ARCHIVE_REPO_MIRROR to configure a custom archive repository mirror URL.
  2. A new --archive flag to check whether the selected Jenkins version is available in the archived repositories. If the version is archived, the tool will fetch metadata from the archive repository.

This allows users to specify an alternative archive repository mirror, making it easier to work with repository mirrors, especially in environments with proxies like Sonatype Nexus Repository.

If no custom URL is provided, the default value https://archives.jenkins.io/ will be used, ensuring backward compatibility.

Changes

CliOptions.java:

  • Added the --archive flag to specify if the tool should use archived update center metadata for plugin dependencies.
  • Added the --jenkins-archive-repo-mirror CLI option to allow specifying a custom archive repository mirror URL.

Config.java:

  • Added support for storing and retrieving the custom archive repository mirror URL.
  • Added a method isUseArchiveAll() to check if the --archive flag is set and whether to use archived repository metadata.

Settings.java:

  • Introduced a default URL constant for the archive repository mirror.

PluginManager.java:

  • Updated to use the custom archive repository URL if specified, falling back to the default if not.
  • Added logic to check if the Jenkins version exists in the archive repository based on the --archive flag. If the version is archived, the tool will use the update center URL from the archive repository.

PluginManagerUtils.java:

  • Added the resolveArchiveUpdateCenterUrl() method to resolve the URL for the update center based on the Jenkins version and the provided archive mirror URL.
  • Updated URL validation and construction logic to support the archive update center URLs.

Tests:

  • Updated ConfigArchiveRepoTest.java to test the new --jenkins-archive-repo-mirror CLI option and the --archive flag.
  • Added tests to verify that the tool correctly handles both default and custom archive repository URLs and the functionality of the --archive flag.

Testing done

Command-line option tests:

  • Updated ConfigArchiveRepoTest.java to test the new --jenkins-archive-repo-mirror CLI option.

Archive version checks:

  • Added tests to verify the functionality of the --archive flag, checking whether the Jenkins version exists in the archive repository and whether the correct update center URL is used.

Environment variable tests:

  • Environment variable tests for JENKINS_ARCHIVE_REPO_MIRROR are not yet implemented but can be added if necessary.

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
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Added a new CLI option --jenkins-archive-repo-mirror and environment variable JENKINS_ARCHIVE_REPO_MIRROR to specify a custom URL for the Jenkins plugin archive repository. The CLI option takes precedence over the environment variable, and if neither is provided, a default URL is used. Updated Config, Settings, and PluginManager classes to support this feature. Includes new tests for validation.
xT10r added 2 commits January 31, 2025 21:51
Added a new --archive flag to use archived metadata. Implemented URL selection logic in PluginManager based on the flag. Added methods in PluginManagerUtils to check and resolve archived URLs. Updated tests to validate the new functionality.
@xT10r xT10r changed the title Add support for custom Jenkins archive repository mirror URL Add parameter to change archive repository URL and check Jenkins version against archive repositories Jan 31, 2025
@xT10r xT10r marked this pull request as ready for review February 1, 2025 20:51
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.

1 participant