1

我想用 Bazel 构建我的 jsonnet。为此,我正在使用 jsonnet 规则。不幸的是,在我的构建管道中,我无法从 github 中提取。因此,我一直在阅读离线版本,但似乎找不到可行的解决方案。我已经提取了 jsonnet 规则 repo 并尝试使用构建 jsonnet

$ bazel test //project ----distdir=<jsonnet_rules_repo>

但这不起作用。所以,我想知道是否有人知道处理这个问题的正确方法?

更新:

这是错误信息

> ERROR: An error occurred during the fetch of repository 'jsonnet_go':
   Traceback (most recent call last):
    File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git.bzl", line 177, column 30, in _git_repository_implementation
        update = _clone_or_update(ctx)
    File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git.bzl", line 36, column 20, in _clone_or_update
        git_ = git_repo(ctx, directory)
    File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 91, column 12, in git_repo
        _update(ctx, git_repo)
    File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 103, column 10, in _update
        fetch(ctx, git_repo)
    File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 129, column 27, in fetch
        _git_maybe_shallow(
    File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 171, column 15, in _git_maybe_shallow
        _error(ctx.name, start + args_list, st.stderr)
    File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 182, column 9, in _error
        fail("error running '%s' while working with @%s:\n%s" % (command_text, name, stderr))
Error in fail: error running 'git fetch origin refs/heads/*:refs/remotes/origin/* refs/tags/*:refs/tags/*' while working with @jsonnet_go:
fatal: unable to access 'https://github.com/google/go-jsonnet/': Could not resolve host: github.com
ERROR: no such package '@jsonnet_go//bazel': error running 'git fetch origin refs/heads/*:refs/remotes/origin/* refs/tags/*:refs/tags/*' while working with @jsonnet_go:
fatal: unable to access 'https://github.com/google/go-jsonnet/': Could not resolve host: github.com

我还将 jsonnet 存储库放在 distdir 文件夹中,但仍然出现此错误。

4

1 回答 1

0

我在一个带有 bazel 的简单 C++ 项目中遇到了同样的问题,我必须在没有互联网连接的 Jenkins 服务器上构建它。这是我的解决方案:使用 Bazel 离线构建 C++ 项目(没有互联网连接)

于 2021-06-27T18:09:30.067 回答