Skip to content

Add Sonatype Nexus repository integration module #262

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

MAVRICK-1
Copy link

@MAVRICK-1 MAVRICK-1 commented Jul 29, 2025

Add Sonatype Nexus Repository Integration Module

Summary

Implements a Coder module for Sonatype Nexus Repository Manager integration that automatically configures Maven, npm, PyPI, and Docker registries for development workspaces.

Demo Video & Screenshots

Screencast.from.2025-07-29.23-34-36.mp4

Nexus Repository Integration

Features

  • Maven Support: Automatic settings.xml configuration
  • npm Support: Automatic .npmrc configuration with scoped packages
  • PyPI Support: Automatic pip.conf configuration
  • Docker Support: Registry authentication setup
  • Flexible Configuration: Support for multiple repositories per package manager
  • Secure Credentials: API token and password support
  • Username Options: Configurable username field (username or email)

Nexus Repository Manager Requirements

Version Requirements

Yes, this module requires Nexus Repository Manager Pro version for full functionality, though basic features work with the Community Edition (OSS).

Supported Authentication Methods

This module supports 4 authentication methods:

  1. User Token Authentication (Recommended - Pro only)

    • Enhanced security with two-part tokens
    • Ideal for CI/CD and automated environments
    • Requires nx-usertoken-current privilege
  2. API Token Authentication (Pro only)

    • Single-use access tokens via REST API
    • Programmatic token generation and management
  3. Basic Authentication (OSS & Pro)

    • Standard HTTP Basic Auth with username/password
    • Works with both OSS and Pro versions
  4. Base64 Encoded Credentials (OSS & Pro)

    • Base64 encoded username:password format
    • Compatible with npm and other package managers

Testing Instructions

Prerequisites

  • Nexus Repository Manager instance (OSS or Pro)
  • Admin access to configure repositories
  • Test repositories for each package manager you want to test

Setup Test Environment

  1. Create Test Repositories in your Nexus instance:

    • Maven: maven-public, maven-releases
    • npm: npm-public, @company:npm-private
    • PyPI: pypi-public, pypi-private
    • Docker: docker-public, docker-private
  2. Configure Authentication:

    • For Pro: Generate user tokens via UI (User menu → User Token)
    • For OSS: Use username/password or base64 encoded credentials
    • Set up appropriate permissions for test repositories
  3. Test the Module:

    module "nexus" {
      source         = "registry.coder.com/mavrickrishi/nexus/coder"
      version        = "1.0.0"
      agent_id       = coder_agent.main.id
      nexus_url      = "https://your-nexus-instance.com"
      nexus_password = var.nexus_api_token  # or password
      package_managers = {
        maven  = ["maven-public", "maven-releases"]
        npm    = ["npm-public", "@company:npm-private"]
        pypi   = ["pypi-public", "pypi-private"]
        docker = ["docker-public", "docker-private"]
      }
    }
  4. Verify Configuration:

    • Check generated config files in workspace
    • Test package installation from configured repositories
    • Verify authentication works for each package manager

EC2 Deployment Testing

Tested by deploying on EC2 instance with:

  • Ubuntu 22.04 LTS
  • Nexus Repository Manager Pro
  • All package managers (Maven, npm, PyPI, Docker)
  • Both token and basic authentication methods

Usage Example

module "nexus" {
  source         = "registry.coder.com/mavrickrishi/nexus/coder"
  version        = "1.0.0"
  agent_id       = coder_agent.main.id
  nexus_url      = "https://nexus.company.com"
  nexus_password = var.nexus_api_token
  package_managers = {
    maven  = ["maven-public", "maven-releases"]
    npm    = ["npm-public", "@company:npm-private"]
    pypi   = ["pypi-public", "pypi-private"]
    docker = ["docker-public", "docker-private"]
  }
}

Testing

  • ✅ 11 comprehensive tests covering all functionality
  • ✅ Variable validation tests
  • ✅ Package manager configuration tests
  • ✅ Error handling tests
  • ✅ All tests passing
  • ✅ EC2 deployment tested

Files Added

  • registry/mavrickrishi/modules/nexus/main.tf - Main module configuration
  • registry/mavrickrishi/modules/nexus/README.md - Complete documentation
  • registry/mavrickrishi/modules/nexus/main.test.ts - Test suite

Checklist

  • Module follows existing patterns and conventions
  • Comprehensive test coverage (11 tests)
  • Complete documentation with examples
  • Input validation and error handling
  • Secure credential handling
  • All tests passing
  • Demo video included
  • Screenshots added
  • Testing instructions provided
  • Authentication methods documented
  • EC2 deployment tested

Closes #202
/claim #202

- Add nexus module with support for Maven, npm, PyPI, and Docker registries
- Includes comprehensive test suite with 11 passing tests
- Supports configurable repositories per package manager
- Automatic configuration of package manager settings
- Secure credential handling with API token support
- Flexible username configuration (username or email)
- Complete documentation with usage examples

Resolves coder#202
Copilot

This comment was marked as outdated.

MAVRICK-1 and others added 4 commits July 30, 2025 00:04
- Fix Terraform formatting with terraform fmt
- Fix README formatting with prettier
- All linting checks now pass
@MAVRICK-1
Copy link
Author

image linting issue fixed

@bpmct
Copy link
Member

bpmct commented Jul 30, 2025

How does the user authenticate their account?

@MAVRICK-1
Copy link
Author

@bpmct through url and password

Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

Left a few suggestions.

@matifali
Copy link
Member

Does it work with https://help.sonatype.com/en/user-tokens.html?

@matifali
Copy link
Member

Also, @michaelbrewer, do you use https://help.sonatype.com/en/user-tokens.html based authentication?

@MAVRICK-1
Copy link
Author

Does it work with https://help.sonatype.com/en/user-tokens.html?

yeah

@MAVRICK-1 MAVRICK-1 requested a review from matifali July 30, 2025 09:38
Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

I think we should rename eModule to be valued Nexus repository as Nexus has multiple other products. Please also update all other references.

---
display_name: Sonatype Nexus Repository
description: Configure package managers to use Sonatype Nexus Repository for Maven, npm, PyPI, and Docker registries.
icon: /.icons/nexus.svg
Copy link
Member

Choose a reason for hiding this comment

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

This is not the correct path. It should be the relative path to .icons/nexus.svg

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a comprehensive Sonatype Nexus Repository integration module for Coder that automatically configures Maven, npm, PyPI, and Docker registries for development workspaces with secure credential handling.

  • Implements a complete Nexus integration module with support for multiple package managers
  • Provides secure credential handling using API tokens and password authentication
  • Includes comprehensive test coverage with 11 tests covering all functionality

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
registry/mavrickrishi/modules/nexus/main.tf Main Terraform module with variable definitions, validation rules, and script configuration
registry/mavrickrishi/modules/nexus/run.sh Shell script that configures package managers (Maven, npm, PyPI, Docker) with Nexus repositories
registry/mavrickrishi/modules/nexus/main.test.ts Comprehensive test suite with 11 tests covering all module functionality
registry/mavrickrishi/modules/nexus/README.md Complete documentation with usage examples for all supported package managers
registry/mavrickrishi/README.md Registry metadata and module listing for the mavrickrishi namespace

@MAVRICK-1
Copy link
Author

image test passed

@MAVRICK-1 MAVRICK-1 requested a review from matifali July 30, 2025 10:31
@matifali
Copy link
Member

One last thing
to make it in parity with JFrog is the go support. Can you add that too? I am setting up a Nexus Repository instance to test it as soon as I can.

@MAVRICK-1
Copy link
Author

@matifali ✅ Go support has been added! The module now supports Maven, npm, Go, PyPI, and Docker - achieving full parity with the JFrog module

@MAVRICK-1
Copy link
Author

image @matifali how to solve this ? my username is mavrick-1

@matifali
Copy link
Member

@MAVRICK-1, can you also rename the module to nexus-repository at all relevant places? Same for icon. Let us be very explicit that this module only enables integration with the Nexus repository. and not all Nexys Sontaype products.

Regarding that false typo, you need to add an exception in .github/typos.toml

- Updated .github/typos.toml to exclude false positives for mavrickrishi's README.md.
- Added nexus-repository.svg icon for the Nexus Repository module.
- Updated README.md for mavrickrishi to reflect the new nexus-repository module.
- Created README.md for the nexus-repository module with detailed configuration instructions.
- Implemented main.tf for the nexus-repository module, defining necessary variables and resources.
- Added main.test.ts for testing the nexus-repository module functionalities.
- Created run.sh script to configure Nexus repository access for various package managers.
@MAVRICK-1
Copy link
Author

@matifali done

Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

Last few suggestions and good to go from my side. I will test it and then give the final approval. Great work so far.

@MAVRICK-1
Copy link
Author

updated both for mavrick and mavrickrishi

@MAVRICK-1 MAVRICK-1 requested a review from matifali July 31, 2025 16:34
@MAVRICK-1
Copy link
Author

MAVRICK-1 commented Aug 4, 2025

image

test failed in other module, @matifali any update ?

Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

Thanks for the Contribution. Can you please linnk the main demo video in the PR body? Also add some intsruction to test it on SonaType Nexus. Does it require a pro version of Nexus Sonatype? What Auth methods are supported?

@MAVRICK-1
Copy link
Author

@matifali yes it required pro, added everything in Pr

@MAVRICK-1
Copy link
Author

image i took a free pro trail by reaching [email protected]

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

Successfully merging this pull request may close these issues.

Add Sonatype Nexus repository integration module
3 participants