eclipse-jkube / jkube

Build and Deploy java applications on Kubernetes
https://www.eclipse.dev/jkube/
Eclipse Public License 2.0
775 stars 520 forks source link

k8s:build jar packaging igonoring some files (when run on Jenkins) #771

Open parapar opened 3 years ago

parapar commented 3 years ago

Description

Info


* Kubernetes / Red Hat OpenShift setup and version :
  N/A
* If it's a bug, how to reproduce :

We have a  simple spring boot react app generated from an archetype. When running mvn k8s:build locally everything seems to be ok. We are able to deploy the image in our minikube. However, we noted that when running the integration pipeline in our Jenkins server the deployed app is faulty. After carefully analysing the differences between the two built images we found that the one produced by Jenkins is different. Long story short the .jar file in the target/docker/.../build/maven/target/ corresponding with our app misses the 'public' folder. However, that 'public' folder is present in target/docker/.../build/maven/target/classes and in the jar created by maven itself in the target folder . We are assuming that the jkube plugin is packaging differently than the default maven packaging strategy. Moreover, that also depends on the settings of our CI system because in our local machines it works as expected.  We tried to locate anything on the Jenkins configuration that will cause this strange behaviour but we have no clue at the moment. We will appreciate any help in understanding the process that the plugin follows to build the jar in order to identify the cause of this problem. 

Jenkins  2.289.1 with: 
JDK  AdoptOpenJDK-11.0.11+9
Maven  3.8.1

* If it's a feature request, what is your use case :

* Sample Reproducer Project : *[GitHub Clone URL]*
rohanKanojia commented 3 years ago

Do you have a sample reproducer project we can try out? Does it only happen on Jenkins or also on some other CI(CircleCI/Github Action etc)?

manusa commented 3 years ago

We will appreciate any help in understanding the process that the plugin follows to build the jar in order to identify the cause of this problem

The JKube plugins are not involved in the packaging of the jar, they however select a Jar to be added to the container image (in case you are using generators).

My only guess is that your jar file is repackaged after the container image is built or that a wrong jar is selected by JKube, I can't see any other explanation for this situation.

As Rohan points out, some way to reproduce this issue would be extremely helpful.

JorgeGabin commented 3 years ago

After some deeper research, we found that the maven-frontend-plugin (used to package together React and Java apps) was not generating the artifacts soon enough to be copied in the JAR. So we bound that plugin to an earlier phase of the maven lifecycle, which fixed the problem.

Thanks for your help.

manusa commented 3 years ago

Great you could fix it, thx for sharing!

manusa commented 3 years ago

BTW, I usually bind those tasks to the generate-resources phase, did you use something else? was this phase causing trouble?

JorgeGabin commented 3 years ago

As we started the project from an existing example, the yarn build generation and the copy of the resources were bound to later phases (package and validate respectively). We are now binding the yarn build generation to the generate-resources phase and copying the resources in the prepare-package phase.

manusa commented 3 years ago

Closing this issue as it seems the problem was fixed.