Jenkins is unable to recognise the Parent Pom file - maven

When I'm running the CI Job locally everything is working as expected. When I'm executing the same via Jenkins, few times it is able to recognize the POM file and few times it is unable to recognize the POM file. And throws the error stating " Non readable POM".
Checked on the docker agent where this job is running and found that Jenkins is only recognizing the file folders but not the POM file (available on the root).
The ls command result proved me that Jenkins is not picking the POM file.

Related

Pom parent property is not being passed to child pom using Jenkins multibranch pipeline

I'm running into a strange issue.
I have a multi-module maven project and in the pom parent I have a property called <build.number> whose default value is latest, then, in a submodule I'm using this property to be part of a docker image tag. Tagging the docker image works fine. Then I use the same property in an other submodule to replace one field in a deployment.yaml file.
So in one module I tag the image an in the other I am pointing to that tagged image.
When I package the pom parent like this:
mvn clean package -Dbuild.number=1
it works fine. The last part of the image tag is -1 and the deployment file is replaced correctly.
What is the issue?
The issue arises when I package the project with Jenkins. I have a multibranch jenkins pipeline. When executing the jenkins pipeline it runs a mvn command like this:
mvn clean package -Dbuild.numer=${BUILD_NUMER}
${BUILD_NUMER} should come from Jenkins.
After the execution, the image is tagged correctly but the field in the deployment.yaml file is replaced but the value is latest, the default value.
This is causing trouble because in the deployment file I must reference the right image. Having this reference pointing to latest it is pointing to a wrong image.
Taking a look at the console logs I can see that the replacement process is being doing fine. One difference I noticed is in the maven.build.properties file which is inside the submodule having the issue. I think this file was created at packaging the submodule. When I package the project locally the property build.number in this file is the one I passed in the command line but when I package it with jenkins, the value in this file is latest.
I don't know if it is an issue about Jenkins, multibranch pipeline, the way we are archiving the files, the location the file is archived or about maven.
NOTE: I had this project working fine before, using a non multibranch pipeline. After a server migration we started to use multibranch pipeline and we did not realize that it was failing until now.

Jenkins path in a pipeline

How can I made my pipeline execute on
Jenkins in /var/jenkins_home/workspace/
instead of
Jenkins in /opt/jenkins/workspace/
To make root pom readable. Because I am getting UNABLE TO READ POM error.
I am building a maven project through a pipeline.
Modify the workspace and build directory path in config.xml
<workspaceDir>${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}</workspaceDir>
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
Path of config.xml is ${JENKINS_HOME}/config.xml
You can save the configuration and restart the jenkins server for the changes to get reflect.

Deploy Maven artifact to remote file system

I have a jar that I am packaging in Maven, that is outputted to my target directory.
I want to put that jar to remote file system (via ssh or sftp) as part of the build process.
I have tried several methods, but nothing seems to work quite right. Any suggestions?

maven error while running sonar from jenkins job

I am trying to implement Sonar in Jenkins CI using maven build tool.I am using Linux machine to build maven with Sonar.
maven is successfully installed. I have tried to configure maven path in Jenkins Configuration,
maven is installed .
whenever I run the job getting below error.
java.io.IOException: Cannot run program "mvn" (in directory
\"/directorypath"): java.io.IOException: error=2, No such file or directory""
as I understood from error that its unable to find out maven in Job directory. what configuration should needed so job can take by default maven path where is installed.
I have searched lot on internet, but could not helped.
Try without mvn in the commands
Eg clean install package

Jenkins: Finding root pom.xml in OSX

Ive been searhcing and I cannot find the path to the pom.xml for ROOT POM in Jenkins Project on my macbook
on my comp, the path is here: /eclipse/.../workspace/test/pom.xml
but when I insert that into the ROOT POM space, the error shows:
ERROR: NO SUCH FILE
/eclipse/.../workspace/test/pom.xml
What do I put to the path to get to my pom? THanks!
Jenkins is on the same machine, and Project is also locally under users on My machine,
Job is configured as "maven project" in jenkin, every thing is on My System

Resources