Something like “mvn undeploy” to remove artifacts from Nexus? - maven

After a mvn deploy (to a local Nexus) on a project with more than 50 modules I realized that the deployed artifacts had all wrong file names (suffix zip instead of war etc).
Is there something like mvn undeploy to remove these from Nexus again?

You can delete it by using Curl command :
http://host:port/nexus/service/local/repositories/repo-id/content/group-id/artifact-id/version
The delete request can be sent with these parameters, I like to suppress the output except HTTP status code, so that it’s easier to check the result of a series of such commands run from shell script.
curl –request DELETE –write “%{http_code} %{url_effective}\\n” –user admin:admin123 –output /dev/null –silent url
For example you can execute this script from a Freestyle jenkins job.

Related

Set up Jenkins to run a specific maven command

I’m new to Jenkins and currently working on a maven project.
I am able to run a simple Jenkins job using maven commands.
mvn clean install
However, the extended requirement requires me to us an additional parameter in the maven command
mvn clean install -DfileName=file1
Is it possible to have a drop down with file names (e.g. file1, file2 ..) and have the user selected one append to the maven command.
mvn clean install -DfileName = {selected filename from dropdown}.
Could some one please assist with this along with what plugin and how can I setup.
Parameterize your jenkins job see https://wiki.jenkins.io/plugins/servlet/mobile?contentId=34930782#content/view/34930782.
Use choice parameter to add your file name choices
Active Choices Plugin - https://wiki.jenkins.io/display/JENKINS/Active+Choices+Plugin
The user selected choice can be used in your maven command using "{params.param_name}".

Where does Jenkins store the project source

I have a Jenkins job that uses a script to build my project. On the following line, the script fails mvn -e -X -Dgit='$git' release:prepare.
Because I want to search for the cause of this, I want to go to the Jenkins server and run mvn -e -X -Dgit='$git' release:prepare from the command line, to see if it works.
Does Jenkins store the projects' source code somewhere, such that I can go to that folder and call Maven?
If yes, then where?
Yes, It Stores the project files for the job by default at
/var/lib/jenkins/workspace/{your-job-name}
This is where jenkins suppose the project files to be present or it pulls it from a source before start working/building from it.
Quote from Andrew M.:
"Hudson/Jenkins doesn't quite work that way. It stores configurations and job information in /var/lib/jenkins by default (if you're using the .deb package). If you want to setup persistence for a specific application, that's something you'll want to handle yourself - Hudson is a continuous integration server, not a test framework.
Check out the Wiki article on Continuous Integration for an overview of what to expect."
From this Question on serverfault.
This worked for me:
/var/jenkins/workspace/JobNameExample
but, if your build machine (node) is a different than the one where Jenkins is running (manager), You need specify it:
/var/jenkins/workspace/JobNameExample/label/NodeName
Where you can define label too:
jenkins stores its workspace files currently in /var/jenkins_home/workspace/project_name
I am running from docker though!

how to get version from jar file in jenkins

I created a job in jenkins with maven for my java project. My jar name is
artifactId-version.jar and I am deploying this jar to artifactory server. I
have 5 to 6 jar files like this which are deployed to artifact.
My build command is
clean install -Dversion=$BUILD_NUMBER -Denv=r -DskipITs
so that my jar is like example-r-23.jar and under execute shell I have written as
echo $BUILD_NUMBER > src/sonarCharts/latest.txt
and sending this file to Artifactory. I am using curl command to read the
value in latest.txt file and downloading jar file.I am downloading them from
my code through shell script (using wget command like wget --user --
password http://artifactory/example-1.0.jar).
This process repeats for every release. Once i deliver my code to production,
i am changing this version to 2.0 and now jar file will be like example-
2.0.jar and deploying it to artifact.I need to change my script file every
time jar version is changed.
<artifactId>rabbitMQHandler</artifactId>
<version>1.0</version>
<name>rabbitMQHandler</name>
<url>http://maven.apache.org</url>
I followed one procedure by overwriting the version with Build number and
passing it from command line as
mvn clean install -Dversion=$BUILD_NUMBER --- to build
and i am sending this BUILD_NUMBER to one txt file as
echo $BUILD_NUMBER > latest.txt --- sending this to artifactory
and placing that file in artifactory. I am reading that txt file through shell
script using curl and i am using that number in wget command.
I feel my way of doing is not correct and is there any other way of doing it.

Run a Curl comand from a jenkins job

can anyone tell me how we can run a curl command from jenkins.
I'm on windows 7 and i'm trying to put .sh on artifactory from a job jenkins.
thanks
So I understand that you want to upload a file to Artifactory by using curl and Artifactory's REST API?
The easiest would be to use the Artifactory plugin, and upload files from your workspace into an Artifactory repository.
If you want to do it without that:
Install cURL for Windows on the node
Add a "Windows batch script" build step, and call cURL with the right URL

How do I build my Spring MVC project with maven then run on my vfabric tomcat server, entirely with command line?

My server runs fine from Eclipse, but I can't get it to run from command line.
Here's what I'm trying, unsuccessfully ("hp-dsat" is the name of my project and also the database name, and project folder that contains pom.xml):
# stop server
cd ~/TcServer/
./tcruntime-ctl.sh myserver/ stop
# import clean sql
dropdb hp-dsat
createdb
psql hp-dsat < ~/hp-dsat/src/main/webapp/resources/data.sql
# build project with maven (doing something wrong here?)
cd ~/hp-dsat
mvn compile
mvn package -Dmaven.test.skip=true
# move the war file to my TcServer
mv -f ~/hp-dsat/target/hp-dsat-1.0.0-BUILD-SNAPSHOT.war ~/TcServer/myserver/webapps/ROOT.war
# start the server back up
cd ~/TcServer/
./tcruntime-ctl.sh myserver/ start
The server starting, but when I visit myserver.com:8080 or myserver.com:8080/hp-dsat (second one is with the context path) it just returns nothing but a blank page.
The thing is, it works if I build the project in eclipse. I just need to figure out how to do it from command line to make a build script to use on a git hook. The server doesn't have eclipse either.
You need to use the cargo deploy plugin in maven, and also might want to look at using jenkins, or another CI server aswell.

Resources