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.
Related
I am newbie to whole maven/pom.xml thing. I need help where I have a pom.xml in Repo1 and in that pom.xml I am using plugin "maven-resources-plugin". In this plugin I need to output specific file to jenkins workspace using <outputDirectory>. And in this, I want to specify path for ${env.WORKSPACE}, I will be using this outputed jenkins workspace file path in groovy script in jenkins. Any idea how I can achieve this?
Thanks.
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.
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.
I am new to CI. I am trying to run my local Selenium Project through Jenkins but it is getting failed with error. Here are the complete details:
OS - MAC OS
local POM xml Path:
Users/prakuma/git/NaveenPOMProject/Naveen_HybridPOM/pom.xml
I am not sure why is /Users/Shared/Jenkins/Home/workspace/Naveen_POMHybrid getting added before my pom.xml path.
I am attaching screen shot of Configuration and Global Setting of Jenkins.
Maven Global
Global setting :
Error:
Please follow the steps given below, which helped me to execute pom.xml successfully through jenkins on macOS.
Click on configuration (of project in jenkins)
Click on Build tab.
Keep Root POM as pom.xml
click on Advance.
search for "Use custom workspace"
check "Use custom workspace" , under Directory give your git dir location where pom.xml is there (eg: /Users/username/git/TestProject/TestProject).
Save.
Give all permission to directory(eg: /Users/username/git/TestProject)
Please click here to get the image
For working with maven jenkins plugin to use local project which is outside jenkins workspace. You can use Copy Data To Workspace Plugin which will move the code to workspace before maven execution.
Give your project folder to in path to folder variable.
Now in Root pom, simply leave it empty or just give pom.xml.
To make Jenkins find the pom.xml in a custom workspace ...
set the jobs Root POM to pom.xml
set Use custom workspace with the path to your pom.xml (e.g. /Users/prakuma/git/NaveenPOMProject/Naveen_HybridPOM/ in this case)
I have a plugin which can run either using a pom.xml or without (depends upon the version of the artifact we're building: new versions go without a pom. Strange, I know).
I want to have that plugin run in Jenkins.
But when creating a maven project, I have to set a pom (or as a default, Jenkins suppose there is one in the base folder given).
Question: Is it possible to configure Jenkins to not use a pom when there is none?
As per my comment, you should use a Jenkins freestyle project build in this case, in order to have more flexibility and avoid the default assumptions of a Jenkins Maven build.
In such a build, you can then configure a build step executing a shell or a Windows command (depending on the Jenkins server OS).
Indeed, in the Jenkins Maven build, a pom file is always required, as mentioned in the help support of the Configuration > Build > Root Pom entry
If your workspace has the top-level pom.xml in somewhere other than the 1st module's root directory, specify the path (relative to the module root) here, such as parent/pom.xml.
If left empty, defaults to pom.xml