|
| 1 | +--- |
| 2 | +display_name: Nexus Repository |
| 3 | +description: Configure package managers to use Sonatype Nexus Repository for Maven, npm, PyPI, and Docker registries. |
| 4 | +icon: ../../../../.icons/nexus-repository.svg |
| 5 | +verified: true |
| 6 | +tags: [integration, nexus-repository, maven, npm, pypi, docker] |
| 7 | +--- |
| 8 | + |
| 9 | +# Sonatype Nexus Repository |
| 10 | + |
| 11 | +Configure package managers (Maven, npm, Go, PyPI, Docker) to use [Sonatype Nexus Repository](https://help.sonatype.com/en/sonatype-nexus-repository.html) with API token authentication. This module provides secure credential handling, multiple repository support per package manager, and flexible username configuration. |
| 12 | + |
| 13 | +```tf |
| 14 | +module "nexus_repository" { |
| 15 | + source = "registry.coder.com/mavrickrishi/nexus-repository/coder" |
| 16 | + version = "1.0.0" |
| 17 | + agent_id = coder_agent.example.id |
| 18 | + nexus_url = "https://nexus.example.com" |
| 19 | + nexus_password = var.nexus_api_token |
| 20 | + package_managers = { |
| 21 | + maven = ["maven-public", "maven-releases"] |
| 22 | + npm = ["npm-public", "@scoped:npm-private"] |
| 23 | + go = ["go-public", "go-private"] |
| 24 | + pypi = ["pypi-public", "pypi-private"] |
| 25 | + docker = ["docker-public", "docker-private"] |
| 26 | + } |
| 27 | +} |
| 28 | +``` |
| 29 | + |
| 30 | +## Requirements |
| 31 | + |
| 32 | +- Nexus Repository Manager 3.x |
| 33 | +- Valid API token or user credentials |
| 34 | +- Package managers installed on the workspace (Maven, npm, Go, pip, Docker as needed) |
| 35 | + |
| 36 | +> [!NOTE] |
| 37 | +> This module configures package managers but does not install them. You need to handle the installation of Maven, npm, Go, Python pip, and Docker yourself. |
| 38 | +
|
| 39 | +## Examples |
| 40 | + |
| 41 | +### Configure Maven to use Nexus repositories |
| 42 | + |
| 43 | +```tf |
| 44 | +module "nexus_repository" { |
| 45 | + source = "registry.coder.com/mavrickrishi/nexus-repository/coder" |
| 46 | + version = "1.0.0" |
| 47 | + agent_id = coder_agent.example.id |
| 48 | + nexus_url = "https://nexus.example.com" |
| 49 | + nexus_password = var.nexus_api_token |
| 50 | + package_managers = { |
| 51 | + maven = ["maven-public", "maven-releases", "maven-snapshots"] |
| 52 | + } |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +### Configure npm with scoped packages |
| 57 | + |
| 58 | +```tf |
| 59 | +module "nexus_repository" { |
| 60 | + source = "registry.coder.com/mavrickrishi/nexus-repository/coder" |
| 61 | + version = "1.0.0" |
| 62 | + agent_id = coder_agent.example.id |
| 63 | + nexus_url = "https://nexus.example.com" |
| 64 | + nexus_password = var.nexus_api_token |
| 65 | + package_managers = { |
| 66 | + npm = ["npm-public", "@mycompany:npm-private"] |
| 67 | + } |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +### Configure Go module proxy |
| 72 | + |
| 73 | +```tf |
| 74 | +module "nexus_repository" { |
| 75 | + source = "registry.coder.com/mavrickrishi/nexus-repository/coder" |
| 76 | + version = "1.0.0" |
| 77 | + agent_id = coder_agent.example.id |
| 78 | + nexus_url = "https://nexus.example.com" |
| 79 | + nexus_password = var.nexus_api_token |
| 80 | + package_managers = { |
| 81 | + go = ["go-public", "go-private"] |
| 82 | + } |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +### Configure Python PyPI repositories |
| 87 | + |
| 88 | +```tf |
| 89 | +module "nexus_repository" { |
| 90 | + source = "registry.coder.com/mavrickrishi/nexus-repository/coder" |
| 91 | + version = "1.0.0" |
| 92 | + agent_id = coder_agent.example.id |
| 93 | + nexus_url = "https://nexus.example.com" |
| 94 | + nexus_password = var.nexus_api_token |
| 95 | + package_managers = { |
| 96 | + pypi = ["pypi-public", "pypi-private"] |
| 97 | + } |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +### Configure Docker registries |
| 102 | + |
| 103 | +```tf |
| 104 | +module "nexus_repository" { |
| 105 | + source = "registry.coder.com/mavrickrishi/nexus-repository/coder" |
| 106 | + version = "1.0.0" |
| 107 | + agent_id = coder_agent.example.id |
| 108 | + nexus_url = "https://nexus.example.com" |
| 109 | + nexus_password = var.nexus_api_token |
| 110 | + package_managers = { |
| 111 | + docker = ["docker-public", "docker-private"] |
| 112 | + } |
| 113 | +} |
| 114 | +``` |
| 115 | + |
| 116 | +### Use custom username |
| 117 | + |
| 118 | +```tf |
| 119 | +module "nexus_repository" { |
| 120 | + source = "registry.coder.com/mavrickrishi/nexus-repository/coder" |
| 121 | + version = "1.0.0" |
| 122 | + agent_id = coder_agent.example.id |
| 123 | + nexus_url = "https://nexus.example.com" |
| 124 | + nexus_username = "custom-user" |
| 125 | + nexus_password = var.nexus_api_token |
| 126 | + package_managers = { |
| 127 | + maven = ["maven-public"] |
| 128 | + } |
| 129 | +} |
| 130 | +``` |
| 131 | + |
| 132 | +### Complete configuration for all package managers |
| 133 | + |
| 134 | +```tf |
| 135 | +module "nexus_repository" { |
| 136 | + source = "registry.coder.com/mavrickrishi/nexus-repository/coder" |
| 137 | + version = "1.0.0" |
| 138 | + agent_id = coder_agent.example.id |
| 139 | + nexus_url = "https://nexus.example.com" |
| 140 | + nexus_password = var.nexus_api_token |
| 141 | + package_managers = { |
| 142 | + maven = ["maven-public", "maven-releases"] |
| 143 | + npm = ["npm-public", "@company:npm-private"] |
| 144 | + go = ["go-public", "go-private"] |
| 145 | + pypi = ["pypi-public", "pypi-private"] |
| 146 | + docker = ["docker-public", "docker-private"] |
| 147 | + } |
| 148 | +} |
| 149 | +``` |
0 commit comments