To use Artifactory as the registry for your Bazel client, you need to complete these two tasks:
Prerequisite: Before connecting the Bazel client to Artifactory, you must have an existing Bazel Modules repository in Artifactory. For more information, see Create a Bazel Modules Repository.
Authenticate Bazel to Artifactory
Before using your Bazel client with Artifactory, you need to add Artifactory authentication information to your netrc file. The credentials are required for Bazel to authenticate to your Artifactory repository.
To authenticate Bazel to Artifactory:
Open the
netrcfile in a text editor. The file location varies by OS, for example:Linux and Unix (macOS):
~/.netrcWindows:
%USERPROFILE%\_netrc
In the
netrcfile, add the following snippet:machine [JFrogPlatformURL] login <USERNAME> password <AUTH>Where:
[JFrogPlatformURL]: Your orgainzation's Artifactory URL<USERNAME>: Your Artifactory username<AUTH>: Your Artifactory identity token
For example:
machine company.jfrog.io login jeffry password k9M4f6V8b2c1n7H3g5T0j2x4R1z9Q5w7E3d8F6c4N2m1K8v0B3s5ASave the changes to your file.
Note
You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see Use Artifactory Set Me Up for Configuring Package Manager Clients.
Add Artifactory Registry to Bazel
After adding Artifactory credentials to your netrc file, you need to configure your Bazel client with the repository information.
To add the Artifactory registry to Bazel:
Open or create the
.bazelrcfile. If the file already exists, its location varies by operating system. For example:Linux and Unix (macOS):
~/etc/bazel.bazelrcWindows:
%ProgramData%\bazel.bazelrc
In the
.bazelrcfile, add the following snippet:<COMMAND> --registry=https://[JFrogPlatformURL]/artifactory/api/bazelmodules/<REPO_NAME>Where:
<COMMAND>: The command you want to configure to work with the Artifactory repository. Options include:common: Set all commands to resolve from Artifactorybuild: Setbuildcommands to resolve from Artifactoryfetch: Setfetchcommands to resolve from Artifactorytest: Settestcommands to resolve from Artifactory
[JFrogPlatformURL]: Your organization's Artifactory URL<REPO_NAME>: The name of your Bazel Modules repository in Artifactory
For example:
common --registry=https://company.jfrog.io/artifactory/api/bazelmodules/bazel-remoteSave the changes to the file.
Note
You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see Use Artifactory Set Me Up for Configuring Package Manager Clients.
Next steps: