为什么在不同的代理商上建立相同的MVN产生不同的结果?
我在Azure管道中对Java应用程序进行的单元测试即使在其他地方构建相同的代码时也可以。失败的单位测试主要是java.lang.noclassdeffounderror类型的错误,对产生的战争文件的检查证实了某些依赖性实际上缺失。
我走到了一切都保持不变,并从Azure的构建代理转换为一个自托管的代理。
结果:
- 自托管:成功
- azure代理:失败
这是我验证的工具链的一部分是相同的:
- Java版本(使用JavatoolInstaller@0)
- Maven版本(确保在自托管上安装相同的MVN版本)代理作为Azure)
- 同一管道,除了构建代理
- 源代码(构建相同的提交)
- 相同的Linux 64bit Architecture
- 没有什么好笑
blew away $ agent_user_home \ .m2目录以确保我从管道本身中检查这些版本 (通过回声vars)。当我说相同时,我的意思是构建数字不仅仅是相似的版本。唯一略有不同的是UNAME显示的版本:5.13.0-1025--azure vs 5.编辑,但这不应该有任何区别
,我缺少有所作为?我认为,如果我有相同的Java,POM,M2和MVN,我可以保证相同的战争。它甚至应该有相同的哈希吗?
我想念什么会造成差异?
谢谢
My unit tests for a Java app in Azure pipelines are failing even though they are fine when I build the same code elsewhere. Failed unit tests are mostly java.lang.NoClassDefFoundError type of errors and inspection of the produced WAR file confirms that some dependencies are in fact missing.
I went as far as keeping everything the same and switching from Azure's build agents to a self hosted one.
Results:
- Self hosted: success
- Azure agent: failure
Here are the parts of the tool-chain that I verified are identical:
- Java version (pulling in specific JDK using JavaToolInstaller@0)
- Maven version (made sure to install identical mvn version on self hosted agent as Azure)
- Same pipeline except for build agent
- Source code (building the same commit)
- Same Linux 64bit architecture
- blew away $AGENT_USER_HOME\.m2 directory to make sure there was nothing funny left over
I'm checking these versions from the pipeline itself (by echoing vars). And when I say identical, I mean that down to build number not just similar version. The only thing that is slightly different is version displayed by uname: 5.13.0-1025-azure vs 5.REDACTED-generic, but that should not make any difference
What am I missing that could make a difference? I thought that if I have the same java,pom,m2 and mvn, I'm guaranteed identical WAR. It should even have the same hash or not?
What am I missing that's creating the difference?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢您的评论,他们帮助我弄清楚了。由于某种原因,我需要从另一个系统中引入一个非常具体的.m2文件夹才能成功。我猜这与“编译”与“运行时”有关。仍然试图弄清楚这一点,但至少现在事情很有意义。
Thanks for the comments, they helped me figure it out. For some reason I needed to bring in a very specific .m2 folder from the other system for things to succeed. I'm guessing this is related to "compile" vs "runtime". Still trying to figure that out, but at least things make sense now.