Closed hundanLi closed 3 years ago
Any help, please?
Have you tried to build from gerrit-review: https://gerrit-review.googlesource.com/admin/repos/plugins/oauth ?
I try, but another error occur:
Traceback (most recent call last):
File "C:/users/hundanli/_bazel_hundanli/3tjlw7g5/external/com_googlesource_gerrit_bazlets/tools/maven_jar.bzl", line 148, column 22, in _maven_jar_impl
out = ctx.execute(args)
Error in execute: Argument 0 of execute is neither a path, label, nor string.
ERROR: D:/developer/project/java/source/oauth/BUILD:10:14: //:oauth__plugin depends on @jackson-databind//jar:jar in repository @jackson-databind which failed to fetch. no such package '@jackson-databind//jar': Argument 0 of execute is neither a path, label, nor string.
ERROR: Analysis of target '//:oauth__plugin' failed; build aborted: Analysis failed
INFO: Elapsed time: 11.019s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (14 packages loaded, 41 targets configured)
Fetching @local_config_cc; fetching
Can you try to build it on Linux? Or just download the recent binary fro GerritForge CI: [1].
[1] https://gerrit-ci.gerritforge.com/view/Plugins-master/job/plugin-oauth-bazel-master-master/
I have try but failed. Since the getUserInfo() method in https://github.com/davido/gerrit-oauth-provider/blob/master/src/main/java/com/googlesource/gerrit/plugins/oauth/CasOAuthService.java is incompatible with cas-5.3,I want to change and build it from source. Here is the incompatible code:
String email = null, name = null, login = null;
if (attrListJson.isJsonArray()) {
// It is possible for CAS to be configured to not return any attributes (email, name,
// login),
// in which case,
// CAS returns an empty JSON object "attributes":{}, rather than "null" or an empty JSON
// array
// "attributes": []
JsonArray attrJson = attrListJson.getAsJsonArray();
for (JsonElement elem : attrJson) {
if (elem == null || !elem.isJsonObject()) {
throw new IOException(String.format("Invalid JSON '%s': not a JSON Object", elem));
}
JsonObject obj = elem.getAsJsonObject();
String property = getStringElement(obj, "email");
if (property != null) email = property;
property = getStringElement(obj, "name");
if (property != null) name = property;
property = getStringElement(obj, "login");
if (property != null) login = property;
}
}
I have try but failed.
Can you provide full build error message when building on Linux?
You could also try to build the plugin in gerrit tree mode: [1]. It should just work.
Can you build gerrit itself? Just clone gerrit recursively and run:
$ bazel build :release
Such errors on Linux:
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
DEBUG: Rule 'com_googlesource_gerrit_bazlets' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1596025598 +0200"
DEBUG: Repository com_googlesource_gerrit_bazlets instantiated at:
/root/oauth/WORKSPACE:5:13: in <toplevel>
/root/oauth/bazlets.bzl:9:23: in load_bazlets
Repository rule git_repository defined at:
/root/.cache/bazel/_bazel_root/683cfed632be4ca27011e5aef37cdabe/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
INFO: Repository gerrit_plugin_api instantiated at:
/root/oauth/WORKSPACE:15:11: in <toplevel>
/root/.cache/bazel/_bazel_root/683cfed632be4ca27011e5aef37cdabe/external/com_googlesource_gerrit_bazlets/gerrit_api.bzl:23:14: in gerrit_api
Repository rule maven_jar defined at:
/root/.cache/bazel/_bazel_root/683cfed632be4ca27011e5aef37cdabe/external/com_googlesource_gerrit_bazlets/tools/maven_jar.bzl:163:28: in <toplevel>
ERROR: An error occurred during the fetch of repository 'gerrit_plugin_api':
Traceback (most recent call last):
File "/root/.cache/bazel/_bazel_root/683cfed632be4ca27011e5aef37cdabe/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, /root/.cache/bazel/_bazel_root/683cfed632be4ca27011e5aef37cdabe/external/com_googlesource_gerrit_bazlets/tools/download_file.py, "-o", /root/.cache/bazel/_bazel_root/683cfed632be4ca27011e5aef37cdabe/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:///root/.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 /root/.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', '/root/.gerritcodereview/bazel-cache/downloaded-artifacts/gerrit-plugin-api-3.3.0-SNAPSHOT.jar-d1479b2c8c45f3712a466f2b53c4d610390a01e8', 'file:///root/.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: /root/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, /root/.cache/bazel/_bazel_root/683cfed632be4ca27011e5aef37cdabe/external/com_googlesource_gerrit_bazlets/tools/download_file.py, "-o", /root/.cache/bazel/_bazel_root/683cfed632be4ca27011e5aef37cdabe/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:///root/.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 /root/.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', '/root/.gerritcodereview/bazel-cache/downloaded-artifacts/gerrit-plugin-api-3.3.0-SNAPSHOT.jar-d1479b2c8c45f3712a466f2b53c4d610390a01e8', 'file:///root/.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__plugin' failed; build aborted: Analysis failed
INFO: Elapsed time: 232.722s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (24 packages loaded, 381 targets c\
onfigured)
You are building in standalone mode, in oauth plugin directory. A pre-requisite for that is to build and publish plugin API in local maven repository.
Check the documentation.
Or try to build in gerrt in tree mode.
Link oauth directory into gerrit's plugins directory and copy external_plugin_deps.bzl
from oauth directory into gerrit's plugins directory and then run:
$ bazel build plugins/oauth
An error occurs following your guide:
[root@10-7-136-22 gerrit]# bazel build plugins/oauth
INFO: Invocation ID: 880a6966-5f70-4aef-938b-c02a5ef17128
DEBUG: /root/.cache/bazel/_bazel_root/8eda2b502a7e650827d9f7c001f5e796/external/bazel_toolchains/rules/rbe_repo/version_check.bzl:68:14:
Current running Bazel is ahead of bazel-toolchains repo. Please update your pin to bazel-toolchains repo in your WORKSPACE file.
DEBUG: /root/.cache/bazel/_bazel_root/8eda2b502a7e650827d9f7c001f5e796/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:125:14: rbe_default not using checked in configs; Bazel version 3.7.1 was picked/selected but no checked in config was found in map {"0.20.0": ["8.0.0"], "0.21.0": ["8.0.0"], "0.22.0": ["8.0.0", "9.0.0"], "0.23.0": ["8.0.0", "9.0.0"], "0.23.1": ["8.0.0", "9.0.0"], "0.23.2": ["9.0.0"], "0.24.0": ["9.0.0"], "0.24.1": ["9.0.0"], "0.25.0": ["9.0.0"], "0.25.1": ["9.0.0"], "0.25.2": ["9.0.0"], "0.26.0": ["9.0.0"], "0.26.1": ["9.0.0"], "0.27.0": ["9.0.0"], "0.27.1": ["9.0.0"], "0.28.0": ["9.0.0"], "0.28.1": ["9.0.0"], "0.29.0": ["9.0.0"], "0.29.1": ["9.0.0", "10.0.0"], "1.0.0": ["9.0.0", "10.0.0"], "1.0.1": ["10.0.0"], "1.1.0": ["10.0.0"], "1.2.0": ["10.0.0"], "1.2.1": ["10.0.0"], "2.0.0": ["10.0.0"], "2.1.0": ["10.0.0"], "2.1.1": ["10.0.0", "11.0.0"], "2.2.0": ["11.0.0"], "3.0.0": ["11.0.0"], "3.1.0": ["11.0.0"]}
ERROR: /root/gerrit/lib/BUILD:49:13: //lib:jgit-ssh-jsch depends on @jgit//org.eclipse.jgit.ssh.jsch:ssh-jsch in repository @jgit which failed to fetch. no such package '@jgit//org.eclipse.jgit.ssh.jsch': No WORKSPACE file found in /root/.cache/bazel/_bazel_root/8eda2b502a7e650827d9f7c001f5e796/external/jgit
ERROR: Analysis of target '//plugins/oauth:oauth' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.480s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
You cloned gerrit not recusrively, and missed git modules
. JGit submodule is missing.
Here are the commands how to build the plugin:
$ mkdir /tmp/build
$ cd /tmp/build
$ git clone --recurse-submodules https://gerrit.googlesource.com/gerrit gerrit
$ cd gerrit
$ bazel build :gerrit
$ cd plugins
$ git clone https://gerrit.googlesource.com/plugins/oauth
$ cd ..
$ cp plugins/oauth/external_plugin_deps.bzl plugins
$ bazel build plugins/oauth
INFO: Invocation ID: 2d0bc7e7-c18a-4b4a-aac1-0f56b0ef6250
DEBUG: /home/davido/.cache/bazel/_bazel_davido/496771e6fd159c87df977b2e99ede97d/external/bazel_toolchains/rules/rbe_repo/version_check.bzl:59:14:
Current running Bazel is not a release version and one was not defined explicitly in rbe_autoconfig target. Falling back to '3.1.0'
INFO: Analyzed target //plugins/oauth:oauth (111 packages loaded, 692 targets configured).
INFO: Found 1 target...
Target //plugins/oauth:oauth up-to-date:
bazel-bin/plugins/oauth/oauth.jar
INFO: Elapsed time: 27.123s, Critical Path: 21.65s
INFO: 50 processes: 6 remote cache hit, 4 internal, 38 linux-sandbox, 2 worker.
INFO: Build completed successfully, 50 total actions
$ ls -all bazel-bin/plugins/oauth/oauth.jar
-r-xr-xr-x 1 davido users 2581987 Dec 8 20:27 bazel-bin/plugins/oauth/oauth.jar
Can you try exactly the above commands?
It works well! Thank you very much for your help!
When I build with bazel of version 3.7.1 on Windows10,it occurs such errors:
Any help, please?