Install the JF CLI and authenticate package managers with Artifactory using OAuth configured via the Coder external-auth
feature.
1module "jfrog" { 2 source = "registry.coder.com/modules/jfrog-oauth/coder" 3 version = "1.0.19" 4 agent_id = coder_agent.example.id 5 jfrog_url = "https://example.jfrog.io" 6 username_field = "username" # If you are using GitHub to login to both Coder and Artifactory, use username_field = "username" 7 8 package_managers = { 9 npm = ["npm", "@scoped:npm-scoped"] 10 go = ["go", "another-go-repo"] 11 pypi = ["pypi", "extra-index-pypi"] 12 docker = ["example-docker-staging.jfrog.io", "example-docker-production.jfrog.io"] 13 } 14}
Note This module does not install
npm
,go
,pip
, etc but only configure them. You need to handle the installation of these tools yourself.
This module is usable by JFrog self-hosted (on-premises) Artifactory as it requires configuring a custom integration. This integration benefits from Coder's external-auth feature and allows each user to authenticate with Artifactory using an OAuth flow and issues user-scoped tokens to each user. For configuration instructions, see this guide on the Coder documentation.
Configure the Python pip package manager to fetch packages from Artifactory while mapping the Coder email to the Artifactory username.
1module "jfrog" { 2 source = "registry.coder.com/modules/jfrog-oauth/coder" 3 version = "1.0.19" 4 agent_id = coder_agent.example.id 5 jfrog_url = "https://example.jfrog.io" 6 username_field = "email" 7 8 package_managers = { 9 pypi = ["pypi"] 10 } 11}
You should now be able to install packages from Artifactory using both the jf pip
and pip
command.
1jf pip install requests
1pip install requests
The JFrog extension for VS Code allows you to interact with Artifactory from within the IDE.
1module "jfrog" { 2 source = "registry.coder.com/modules/jfrog-oauth/coder" 3 version = "1.0.19" 4 agent_id = coder_agent.example.id 5 jfrog_url = "https://example.jfrog.io" 6 username_field = "username" # If you are using GitHub to login to both Coder and Artifactory, use username_field = "username" 7 configure_code_server = true # Add JFrog extension configuration for code-server 8 package_managers = { 9 npm = ["npm"] 10 go = ["go"] 11 pypi = ["pypi"] 12 } 13}
JFrog Access token is also available as a terraform output. You can use it in other terraform resources. For example, you can use it to configure an Artifactory docker registry with the docker terraform provider.
1provider "docker" { 2 # ... 3 registry_auth { 4 address = "https://example.jfrog.io/artifactory/api/docker/REPO-KEY" 5 username = module.jfrog.username 6 password = module.jfrog.access_token 7 } 8}
Here
REPO_KEY
is the name of docker repository in Artifactory.