2

I'm very new to Bazel and in my Bazel BUILD project, I'll try to explain use case which I'm trying to achieve,

  1. I have dependency on third party libraries from artifacts.
  2. I want to include the download part from the url in Bazel build.
  3. I have added below part in my WORKSPACE file.
    http_archive(
        name = "<lib_name>",
        sha256 = "< >",
        strip_prefix = "<../..>",
        url = " < url/../xyz.zip", 
    )
  1. Now, how can I use private access tokens to download and extract libraries from artifact ?
  2. What modification do I need to do in BUILD file ?

1 Answer 1

0

Your question has 2 parts:

how can I use private access tokens to download[?]

Since this is a WORKSPACE file (which is in source control), it is generally frowned upon to put creds directly in this file. Bazel 7.0 supports --credential_helper which you should use for this. But that means, the runtime (or your CI) would need to provide have a creds helper.

See more in EngFlow's blog: Configuring Bazel's Credential Helper

If you are just running locally - I've had success putting creds in ~/.netrc file.

[how can I] extract libraries from artifact?

bazel will do this for you. It support a lot of the popular compression formats. From the http_archive docs:

Downloads a Bazel repository as a compressed archive file, decompresses it, and makes its targets available for binding.

It supports the following file extensions: "zip", "jar", "war", "aar", "tar", "tar.gz", "tgz", "tar.xz", "txz", "tar.zst", "tzst", tar.bz2, "ar", or "deb".

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.