'jenkins build and push docker image jenkins

I have a Jenkins pipeline to build and push docker image to Nexus the maven project is composed of 3 submodules like this:

+pom.xml
+api folder
  ----->  Dockerfile
+core folder
    -----> Dockerfile
+test
    -----> pom.xml

docker.withRegistry("https://" + dockerRegistry, jenkinsCredential) {
 dockerImage = docker.build tagImage
 //  dockerImage.push()
  } 

the problem is that the Dockerfile does not exist in the main project that's why I have this error: unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat no such file or directory is there any solution please?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source