JetBrains / teamcity-bazel-plugin

TeamCity plugin for Bazel build system
Apache License 2.0
14 stars 6 forks source link

Fails to parse latest bazel version #1

Closed jameshartig closed 5 years ago

jameshartig commented 5 years ago

After installing bazel on CentOS 7 following: https://docs.bazel.build/versions/master/install-redhat.html

# bazel version
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
INFO: Invocation ID: 3cc42df3-2475-42e5-8f1a-d69d81835b66
Build label: 0.22.0- (@non-git)
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jan 29 18:22:45 2019 (1548786165)
Build timestamp: 1548786165
Build timestamp as int: 1548786165

The teamcity agent gives the following error on startup:

WARN - Server.bazel.BazelToolProvider - Failed to parse bazel.version version: null: Unexpected character 'EOI(null)' at position '7', expecting '[DIGIT, LETTER, HYPHEN]' (enable debug to see stacktrace)
WARN - Server.bazel.BazelToolProvider - Unable to locate tool bazel in system. Please make sure to add it in the PATH variable
dtretyakov commented 5 years ago

@fastest963, thanks for reporting. We should somehow sanitize such version values 0.22.0- (@non-git).

NikolayPianikov commented 5 years ago

Fixed here

jameshartig commented 5 years ago

Thanks for the quick fix!

jameshartig commented 5 years ago

Actually @NikolayPianikov I just had a chance to test it and there's still an issue. Now I get:

WARN - Server.bazel.BazelToolProvider - Failed to parse bazel.version version: null: Unexpected character 'LETTER(B)' at position '0', expecting '[DIGIT]' (enable debug to see stacktrace)

I think that's because you added a $ and without the RegexOption.MULTILINE option, the $ will only match the end of the string, not the end of the line and the result of bazel version is multiple lines:

$ bazel version 2>/dev/null
Build label: 0.22.0- (@non-git)
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jan 29 18:22:45 2019 (1548786165)
Build timestamp: 1548786165
Build timestamp as int: 1548786165
NikolayPianikov commented 5 years ago

@fastest963 you are right, here is fixed version

jameshartig commented 5 years ago

@NikolayPianikov it looks like it works now! There was a few warnings and an exception but I see bazel.version in the agent's properties.

[2019-02-13 16:45:35,226]   WARN - Server.bazel.BazelToolProvider - Failed to parse bazel.version version: null: Unexpected character 'LETTER(B)' at position '0', expecting '[DIGIT]' (enable debug to see stacktrace)
[2019-02-13 16:45:35,226]   WARN - Server.bazel.BazelToolProvider - Failed to parse bazel.version version: null: Unexpected character 'LETTER(B)' at position '0', expecting '[DIGIT]' (enable debug to see stacktrace)
[2019-02-13 16:45:35,227]   WARN - Server.bazel.BazelToolProvider - Failed to parse bazel.version version: null: Unexpected character 'LETTER(B)' at position '0', expecting '[DIGIT]' (enable debug to see stacktrace)
[2019-02-13 16:45:35,227]   WARN - Server.bazel.BazelToolProvider - Failed to parse bazel.version version: null: Unexpected character 'LETTER(B)' at position '0', expecting '[DIGIT]' (enable debug to see stacktrace)
[2019-02-13 16:45:35,228]   WARN - Server.bazel.BazelToolProvider - Failed to parse bazel.version version: Input string is NULL or empty
java.lang.IllegalArgumentException: Input string is NULL or empty
at com.github.zafarkhaja.semver.VersionParser.<init>(VersionParser.java:162)
at com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:194)
at com.github.zafarkhaja.semver.Version.valueOf(Version.java:265)
at jetbrains.buildServer.bazel.BazelToolProvider.tryParseVersion(BazelToolProvider.kt:78)
at jetbrains.buildServer.bazel.BazelToolProvider$findVersions$8.invoke(BazelToolProvider.kt:71)
at jetbrains.buildServer.bazel.BazelToolProvider$findVersions$8.invoke(BazelToolProvider.kt:21)
at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:149)
at kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:109)
at kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:133)
at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:153)
at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:647)
at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(_Sequences.kt:677)
at kotlin.sequences.SequencesKt___SequencesKt$sortedWith$1.iterator(_Sequences.kt:546)
at kotlin.sequences.SequencesKt___SequencesKt.firstOrNull(_Sequences.kt:125)
at jetbrains.buildServer.bazel.BazelToolProvider.beforeAgentConfigurationLoaded(BazelToolProvider.kt:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at jetbrains.buildServer.util.EventDispatcher$3.run(EventDispatcher.java:128)
at jetbrains.buildServer.util.NamedThreadFactory.executeWithNewThreadName(NamedThreadFactory.java:76)
at jetbrains.buildServer.util.EventDispatcher.dispatch(EventDispatcher.java:122)
at jetbrains.buildServer.util.EventDispatcher$2.invoke(EventDispatcher.java:72)
at com.sun.proxy.$Proxy8.beforeAgentConfigurationLoaded(Unknown Source)
at jetbrains.buildServer.agent.impl.BuildAgentImpl.init(BuildAgentImpl.java:795)
at jetbrains.buildServer.agent.AgentMain2.startAgent(AgentMain2.java:203)
at jetbrains.buildServer.agent.AgentMain2.main2(AgentMain2.java:79)
at jetbrains.buildServer.agent.AgentMain2.main(AgentMain2.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at jetbrains.buildServer.agent.AgentMain.main(AgentMain.java:43)
NikolayPianikov commented 5 years ago

@fastest963 thanks for info, yes I saw it, I will transform these exceptions to more appropriate form in the log