简体   繁体   English

在Jenkins上运行时,Java Maven项目无法正确地(一致地)编译

[英]Java Maven project won't compile properly(consistently) when running on Jenkins

I have a Java Maven project that compiles and works just fine on my local machine. 我有一个Java Maven项目,该项目可以在本地计算机上编译并正常运行。 However when I try to run from Jenkins, it fails miserably with a bunch of bizarre errors. 但是,当我尝试从詹金斯(Jenkins)运行时,它由于一系列奇怪的错误而惨败。 It won't even compile complaining that one of the method constructors can't accept the current set of arguments which it definitely can and works that way perfectly on my local machine. 它甚至不会抱怨一个方法构造函数不能接受当前的参数集,而它肯定可以并且在我的本地计算机上可以完美地工作。

I tried to update Maven plug-in for Jenkins, restart it but frankly, I don't have a slightest idea what could possibly go wrong? 我尝试为Jenkins更新Maven插件,然后重新启动它,但坦率地说,我一点儿也不知道可能会出什么问题?

I will be happy to hear ANY theories of what could go wrong and how a working project can't even be complied all of a sudden. 我将很高兴听到任何关于可能出问题以及如何突然无法正常运行项目的理论。

I realize that the description is a bit vague but didn't want post garbage but happy to share any additional info if required. 我意识到说明有点含糊,但不想张贴垃圾,但愿意在需要时分享任何其他信息。

Example : 范例

Below you can find and example of the error code. 您可以在下面找到错误代码和示例。 Generally cannot find symbol error means that compiler doesn't understand what this expression is. 通常cannot find symbol错误意味着编译器不理解该表达式是什么。 But please mind that these errors have nothing to do with the correctness of the original code as it works fine locally. 但是请注意,这些错误与原始代码的正确性无关,因为它在本地可以正常工作。 Moreover, I found that committing meaningless space symbols sometimes helps and the build successfully completes ! 此外,我发现提交无意义的空格符号有时会有所帮助,并且构建成功完成 These errors might vary as well. 这些错误可能也会有所不同。

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] C:\.jenkins\path\ParseResultsTest.java:[113,44] error: cannot find symbol
[ERROR]   symbol:   method getScenarios()
  location: variable ffe of type FeatureFileElement
C:\.jenkins\path\ParseResultsTest.java:[114,93] error: cannot find symbol
[ERROR]   symbol:   method getRunResult()
  location: variable scenario of type Scenario
C:\.jenkins\path\ParseResultsTest.java:[203,42] error: cannot find symbol
[ERROR]   symbol:   method getScenarioName()
  location: variable scenario of type Scenario
C:\.jenkins\path\ParseResultsTest.java:[210,68] error: cannot find symbol
[INFO] 4 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.704 s
[INFO] Finished at: 2015-08-11T15:06:26+08:00
[INFO] Final Memory: 19M/190M
[INFO] ------------------------------------------------------------------------

Checkpoints from my experience 从我的经验来看的检查要点

  1. java version mentioned in maven and Jenkins should be same maven和Jenkins中提到的Java版本应该相同
  2. Repository used by maven in both local and jenkins should be same and Jenkins should able to access the repository Maven在本地和jenkins中使用的存储库应该相同,并且Jenkins应该能够访问该存储库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM