Home > Enterprise >  Why is identical mvn build on different agents producing different results?
Why is identical mvn build on different agents producing different results?

Time:06-27

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

CodePudding user response:

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.

  • Related