Jenkins workspace as a output path in pom.xml - maven

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.

Related

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.

Jenkins : Unable to Run Local Maven Project through Jenkins

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)

Copy file after successful build using maven

I'm using mvn install to build the .hpi to my plugin for Jenkins. This puts a .hpi in the target folder.
What I would like to do is if the build is successful, copy the hpi-file to a specific folder. Is it possible to do both these task with one Maven command using only the terminal/command prompt?
edit
My POM can be seen here.
https://github.com/MarkusDNC/plot-plugin/blob/master/pom.xml
There is now way to copy file through MVN CMD.
After that being said - You have 2 options:
1.) using a simple shell/batch step to copy.
2.) You need to Add another build step for maven but you will also need a new pom.xml file and use maven-antrun-plugin

How to use ANT in Cloudbees

I'm trying to move an existing ANT build script (build.xml) into Cloudbees for CI using Jenkins. I setup the project repository using GitHub. The build pulls the repository into the Cloudbees Workspace successfully, but then fails with this message.
Parsing POMs
ERROR: No such file /scratch/jenkins/workspace/project/pom.xml
Perhaps you need to specify the correct POM file path in the project configuration?
I'm not too familiar with this, but from what I can tell (thanks Google) it's because Cloudbees uses Maven instead of ANT. Is there a way that I can change Jenkins to run the ANT build script instead of using Maven? Or a simple way to execute my ANT scripts from Maven? Any help here would be appreciated!
Thanks
You do not need a Maven POM file if your project is Ant-based.
It sounds like you created a Maven job in Jenkins. Delete it and create a free-style job instead, then (as #thekbb says) click Add build step and select Invoke Ant and configure as needed.
ant support is provided by teh ant plugin, I think you get this automatically when installing jenkins. In your jenkins job, add a build step of type 'Invoke Ant' and provide the target.

maven's pom.xml ordering

I want to checkout code from svn, then compile it and then copy it to a remote location and then deploy the war file. can you please provide me a sample pom.xml file in which all these tasks have been performed in the above given ordering.
You can't do that in the POM cause Maven is not Ant...you can do that by using Jenkins/Hudson or any other CI solution.
Jenkins+Hudson can do this... But It don't mean that it cannot be done in Pom.xml. We can also use combination of ant scripts in pom.xml and we can use Maven AntRun Plugin to execute them. So by maven we can checkout code from svn, then compile it and then copy it to a remote location and then deploy the war file.
Check out this Usage Page

Resources