ARTIFACTORY: How to authenticate to Bazel client from Artifactory and perform Bazel builds

AuthorFullName__c
Dinesh Selvakamesh
articleNumber
000006113
FirstPublishedDate
2024-06-03T13:05:23Z
lastModifiedDate
2025-07-22

ARTIFACTORY: How to authenticate to Bazel client from Artifactory and perform Bazel builds

Setting up authentication to Bazel client from Artifactory: 
You can refer to this documentation to integrate Bazel with Artifactory and in order to set up authentication we will have to pass the credentials using a .netrc file. We need to create a .netrc file in the HOME directory as below: 

machine test.jfrog.io login <username> password <password/token>


Set the permissions for the .netrc file to ensure that only the owner can read and write to it, as it may contain sensitive information like login credentials:

chmod 600 ~/.netrc


For the Maven dependencies, we can add the authentication details in the WORKSPACE file under the repository block as shown below:

maven_install(
    artifacts =
        IO_GRPC_GRPC_JAVA_ARTIFACTS + [
            "com.google.code.gson:gson:2.10.1",
            "com.google.googlejavaformat:google-java-format:1.17.0",
            "io.helidon.grpc:helidon-grpc-core:3.2.5",
            "org.bouncycastle:bcprov-jdk15on:1.70",
            "junit:junit:4.13.2",
            "org.mockito:mockito-core:4.5.1",
        ],
    fail_if_repin_required = True,
    generate_compat_repositories = True,
    override_targets = IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS,
    repositories = [
        "https://admin:password@test.jfrog.io/artifactory/test-libs-release",
    ],
)


Once the authentication is configured, you can modify your WORKSPACE file with respect to the Artifactory repositories and perform Bazel build to resolve the GitHub and Maven dependencies via Artifactory.