Configuration for pom.xml to buil an rpm - pom.xml

I have a below folder structure :
/a/b/c/test.sh
location of POM : /a/pom.xml
I need a pom.xml file for generating rpm for this.
Condition: When deploying this rpm the script test.sh should automatically run.
Please help.

MojoHaus maintains an RPM plugin for Maven that will help build an RPM as part of your Maven build. You can also take a look at this example pom.xml file to help you get started.

Related

How to define POM location in Jenkins that is installed on a remote PC

I have jenkins installed on a remote machine. How can I point my POM location in Jenkins. If I give the POM.xml location as C:\Automation\pom.xml I am getting the error no such file exists.
Started by user anonymous
Building in workspace C:\Users\Administrator\.jenkins\workspace\RegressionTestJob
Parsing POMs
ERROR: No such file C:\Automation\pom.xml
Perhaps you need to specify the correct POM file path in the project configuration?
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/testng-results.xml
Did not find any matching files.
Finished: FAILURE
Your pom should be in your workspace, like how you would build your project in an IDE e.g. eclipse and when you build your project Jenkins will find the pom on its own in the workspace and build the project
Incase you still wish to specify the location you can use the -f option
mvn -f PomFile.xml
Hope it helps :)

How to run a jar file generated by maven in Jenkins Job Builder

I have a maven project (assume it is just a simple hello-world java program) in git. Now I want to (1) create the jar file; (2) run this jar file. How can I do this through Jenkins Job Builder hourly (like every one hour Jenkins will build the jar file, and execute it)? Thanks.
First of all, create a Jenkins Freestyle Project.
TZ=Asia/Kolkata
0 */1 * * *
Please add the above code in Build periodically box. It will run your code once an hour. For creating the jar file,
cd '<your project location in the disk>'
mvn clean install
Now this will build your jar file. To run the jar file,
cd 'target'
java -jar <project jar file name>.jar
So total script will be like :
cd '<your project location in the disk>'
mvn clean install
cd 'target'
java -jar <project jar file name>.jar
Add the above code to Execute shell block in Build -> Add build step -> Execute shell in the job configuration. Hope this is what you are looking for.

Jar versioning in Jenkins

On each maven build or release, how to get new jar version in Jenkins. I have tried it in Jenkins but only getting same jar file name as it is in pom file.
you can use maven-exec-plugin to print the version to stdout or write it in a file:
mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:exec

Maven - How to force maven to consider my updated jar from local maven repository

I have a question related to maven - generating a war. Please see below.
- In one of my project (war), I am using a 3rd party jar (-SNAPSHOT version) whose entry I have made into my project pom.xml. So far it gets bundled correctly into the project war.
- But we encountered one issue in one of the java file inside this jar. For which my developer took the source code for the jar and modified-compiled and updated the jar file into local maven_repo directory.
- But whenever I build the project using maven clean:install command, my updated jar gets deleted from my local maven-repo dir and a fresh copy is downloaded from remote maven repo (where the actual 3rd party jar resides).
Can someone please help on this how can I manage so that maven use my modified jar and does not replace it with old jar during build process.
I am using maven-3.2.5.
you can run maven offline by running with the "-o" argument.
Example:
mvn clean install -o
Keep in mind that this will affect all your other dependencies and your need to have all the dependencies in your local .m2 repository.
Here is another thread taking up the issue of running maven offline:
How do I configure Maven for offline development?

Building a Maven Project with Files in a Local Repo

I've installed two libraries to my local repository (JGraph and JGraphtT). I used this command:
mvn install:install-file -DgroupId=org.jgrapht -DartifactId=jgrapht -Dversion=0.8.3 -Dpackaging=jar -Dfile=./jgrapht.jar
and similar for JGraph. I can see that the two Jar files are in my local repository.
When I try to create Eclipse classpath and build files from the directory of my project's POM file (using mvn eclipse:eclipse), I get this error:
[WARNING] Missing POM for org.jrapht:jgrapht:jar:0.8.3
and similar for JGraph.
Any ideas on what I'm doing wrong? My settings.xml file has the local repository enabled.
Thanks,
Keith

Resources