davido / gerrit-oauth-provider

OAuth2 authentication provider for Gerrit Code Review. Please upload changes for review to: https://gerrit-review.googlesource.com/#/admin/projects/plugins/oauth
Apache License 2.0
140 stars 84 forks source link

Build from Master branch is failing #147

Closed fstefanov closed 3 years ago

fstefanov commented 3 years ago
bazel --version
bazel 2.2.0

git rev-parse HEAD
296a0051e1692da91a9b0d3c9b878ac571dc9819

bazel build gerrit-oauth-provider --sandbox_debug --verbose_failures

ERROR: /home/gerrit2/plugins/oauth-provider/BUILD:10:1: Executing genrule //:gerrit-oauth-provider__gen_stamp_info failed (Exit 1): linux-sandbox failed: error executing command
  (cd /home/gerrit2/.cache/bazel/_bazel_gerrit2/bf76389c5f1cd45ff338a06b1beec72d/sandbox/linux-sandbox/1/execroot/com_github_davido_gerrit_oauth_provider && \
  exec env - \
    TMPDIR=/tmp \
  /home/gerrit2/.cache/bazel/_bazel_gerrit2/install/a968348e0a72afc534c7baff88ca46f1/linux-sandbox -t 15 -w /home/gerrit2/.cache/bazel/_bazel_gerrit2/bf76389c5f1cd45ff338a06b1beec72d/sandbox/linux-sandbox/1/execroot/com_github_davido_gerrit_oauth_provider -w /tmp -w /dev/shm -D -- /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; cat bazel-out/stable-status.txt | grep "^STABLE_BUILD_GERRIT-OAUTH-PROVIDER_LABEL" | awk '\''{print $NF}'\'' > bazel-out/host/bin/gerrit-oauth-provider__gen_stamp_info.txt') linux-sandbox failed: error executing command
davido commented 3 years ago

Can you try to build with latest Bazel release 3.6.0, this is the latest Bazel release: https://github.com/bazelbuild/bazel/releases/tag/3.6.0.

Also consider to build oauth plugin from here: https://gerrit.googlesource.com/plugins/oauth.

The latest commits from oauth-plugin were not replicated in this repositories.

Of course you could just grab the binaries from Gerrit CI:

https://gerrit-ci.gerritforge.com/view/Plugins-master/job/plugin-oauth-bazel-master-master/

fstefanov commented 3 years ago

I want to build it locally since I'm planning to add couple changes.

.bazelversion is set to 2.2.0 changed it to 3.6.0 Build is failing with the same error using bazel 3.6.0

git clone https://gerrit.googlesource.com/plugins/oauth

git rev-parse HEAD
ee2d6af619348a083220d2f87961675b300c1d10

rm -rf ~/.cache/bazel/
rm -rf ~/.m2/

.bazelversion is set to 3.5.0 changed it to 3.6.0

bazel build oauth --sandbox_debug --verbose_failures

ERROR: An error occurred during the fetch of repository 'gerrit_plugin_api':
   Traceback (most recent call last):
    File "/home/gerrit2/.cache/bazel/_bazel_gerrit2/df619b1af4178fbd97693b30c0e1aee1/external/com_googlesource_gerrit_bazlets/tools/maven_jar.bzl", line 151, column 13, in _maven_jar_impl
        fail("failed %s: %s" % (args, out.stderr))
Error in fail: failed [/usr/bin/python, /home/gerrit2/.cache/bazel/_bazel_gerrit2/df619b1af4178fbd97693b30c0e1aee1/external/com_googlesource_gerrit_bazlets/tools/download_file.py, "-o", /home/gerrit2/.cache/bazel/_bazel_gerrit2/df619b1af4178fbd97693b30c0e1aee1/external/gerrit_plugin_api/jar/gerrit-plugin-api-3.3.0-SNAPSHOT.jar, "-u", "MAVEN_LOCAL:/com/google/gerrit/gerrit-plugin-api/3.3.0-SNAPSHOT/gerrit-plugin-api-3.3.0-SNAPSHOT.jar"]: Download file:///home/gerrit2/.m2/repository/com/google/gerrit/gerrit-plugin-api/3.3.0-SNAPSHOT/gerrit-plugin-api-3.3.0-SNAPSHOT.jar
curl: (37) Couldn't open file /home/gerrit2/.m2/repository/com/google/gerrit/gerrit-plugin-api/3.3.0-SNAPSHOT/gerrit-plugin-api-3.3.0-SNAPSHOT.jar
error using curl: Command '['curl', '--proxy-anyauth', '-ksSfLo', '/home/gerrit2/.gerritcodereview/bazel-cache/downloaded-artifacts/gerrit-plugin-api-3.3.0-SNAPSHOT.jar-d1479b2c8c45f3712a466f2b53c4d610390a01e8', 'file:///home/gerrit2/.m2/repository/com/google/gerrit/gerrit-plugin-api/3.3.0-SNAPSHOT/gerrit-plugin-api-3.3.0-SNAPSHOT.jar']' returned non-zero exit status 37
INFO: Repository remote_java_tools_linux instantiated at:
  no stack (--record_rule_instantiation_callstack not enabled)
Repository rule http_archive defined at:
  /home/gerrit2/.cache/bazel/_bazel_gerrit2/df619b1af4178fbd97693b30c0e1aee1/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
INFO: Repository remotejdk11_linux instantiated at:
  no stack (--record_rule_instantiation_callstack not enabled)
Repository rule http_archive defined at:
  /home/gerrit2/.cache/bazel/_bazel_gerrit2/df619b1af4178fbd97693b30c0e1aee1/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
ERROR: /home/gerrit2/plugins/oauth/WORKSPACE:15:11: //external:gerrit-plugin-api-neverlink depends on @gerrit_plugin_api//jar:neverlink in repository @gerrit_plugin_api which failed to fetch. no such package '@gerrit_plugin_api//jar': failed [/usr/bin/python, /home/gerrit2/.cache/bazel/_bazel_gerrit2/df619b1af4178fbd97693b30c0e1aee1/external/com_googlesource_gerrit_bazlets/tools/download_file.py, "-o", /home/gerrit2/.cache/bazel/_bazel_gerrit2/df619b1af4178fbd97693b30c0e1aee1/external/gerrit_plugin_api/jar/gerrit-plugin-api-3.3.0-SNAPSHOT.jar, "-u", "MAVEN_LOCAL:/com/google/gerrit/gerrit-plugin-api/3.3.0-SNAPSHOT/gerrit-plugin-api-3.3.0-SNAPSHOT.jar"]: Download file:///home/gerrit2/.m2/repository/com/google/gerrit/gerrit-plugin-api/3.3.0-SNAPSHOT/gerrit-plugin-api-3.3.0-SNAPSHOT.jar
curl: (37) Couldn't open file /home/gerrit2/.m2/repository/com/google/gerrit/gerrit-plugin-api/3.3.0-SNAPSHOT/gerrit-plugin-api-3.3.0-SNAPSHOT.jar
error using curl: Command '['curl', '--proxy-anyauth', '-ksSfLo', '/home/gerrit2/.gerritcodereview/bazel-cache/downloaded-artifacts/gerrit-plugin-api-3.3.0-SNAPSHOT.jar-d1479b2c8c45f3712a466f2b53c4d610390a01e8', 'file:///home/gerrit2/.m2/repository/com/google/gerrit/gerrit-plugin-api/3.3.0-SNAPSHOT/gerrit-plugin-api-3.3.0-SNAPSHOT.jar']' returned non-zero exit status 37
ERROR: Analysis of target '//:oauth' failed; build aborted: Analysis failed
INFO: Elapsed time: 6.305s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (23 packages loaded, 305 targets configured)
    Fetching @jackson-annotations; fetching
davido commented 3 years ago

You are trying to build in standalone build mode. For that you have to publish the Plugin API first. Alternatively, you could build in gerrit tree mode.

Please, check the build documentation: https://gerrit.googlesource.com/plugins/oauth/+/refs/heads/master/src/main/resources/Documentation/build.md

fstefanov commented 3 years ago

Again failing :( https://gerrit.googlesource.com/gerrit master branch - c5d721cce1ee8c603a51de5995e1a07b7d1dcc22 https://gerrit.googlesource.com/plugins/oauth master branch - ee2d6af619348a083220d2f87961675b300c1d10

bazel build plugins/oauth --sandbox_debug --verbose_failures

INFO: Invocation ID: f2d5de86-344d-4c53-9e04-0a3eee3f915b
INFO: Repository remote_java_tools_linux instantiated at:
  no stack (--record_rule_instantiation_callstack not enabled)
Repository rule http_archive defined at:
  /home/gerrit2/.cache/bazel/_bazel_gerrit2/3550a626887a0d3d9bee98341adfd5ba/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
INFO: Repository remotejdk11_linux instantiated at:
  no stack (--record_rule_instantiation_callstack not enabled)
Repository rule http_archive defined at:
  /home/gerrit2/.cache/bazel/_bazel_gerrit2/3550a626887a0d3d9bee98341adfd5ba/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
ERROR: /home/gerrit2/gerrit_source/lib/BUILD:56:13: //lib:jgit-archive depends on @jgit//org.eclipse.jgit.archive:jgit-archive in repository @jgit which failed to fetch. no such package '@jgit//org.eclipse.jgit.archive': No WORKSPACE file found in /home/gerrit2/.cache/bazel/_bazel_gerrit2/3550a626887a0d3d9bee98341adfd5ba/external/jgit
ERROR: Analysis of target '//plugins/oauth:oauth' failed; build aborted: Analysis failed
davido commented 3 years ago

The reason for the failure has nothing to do with this plugin.

You have to clone recursively to build gerrit, so that jgit (and other modules) will be fetched.

ERROR: /home/gerrit2/gerrit_source/lib/BUILD:56:13: //lib:jgit-archive depends on @jgit//org.eclipse.jgit.archive:jgit-archive in repository @jgit which failed to fetch. no such package '@jgit//org.eclipse.jgit.archive': No WORKSPACE file found in /home/gerrit2/.cache/bazel/_bazel_gerrit2/3550a626887a0d3d9bee98341adfd5ba/external/jgit

Really, take time, read the documentation, how to build gerrit:

https://gerrit-review.googlesource.com/Documentation/dev-bazel.html

Unfortunately, this documentation doesn't mention, that the gerrit should be cloned recursively.

And verify that this command works:

  $ bazel build headless

in Gerrit workspace. After that bazel build plugins/oauth shoud just work.

davido commented 3 years ago

This is now fixed, see https://github.com/davido/gerrit-oauth-provider/issues/89#issuecomment-713676936.