How to deploy jar from jenkins to remote window server - jenkins

I have a build jar in Jenkins .I need to deploy the jar into windows VM Machine..I have tried lot of options but i couldn't achieve. Kindly suggest me .. Guidance much appreciate.

I assume that your have an Spring boot executable jar. I'm also assuming that you have jar file located in central repo such as Nexus or Artifactory.
In this case, create a write declarative or scripted pipeline. In one of the build steps execute a batch file with the command below.
java -jar <YourJarFile>.jar
Also make sure the installed java version classpath is set.

Related

Unable to run java file in GITHUB using jenkins

I am new to Jenkins and GITHUB.I have configured Jenkins with GITHUB and I don't see any issues with configuration.
I am running the file using windows batch
My commands are -
javac HelloJenkins.java
java HelloJenkins
Can someone tell me where am I going wrong?
enter image description here

How to debug the Jenkins plugin

I have built a new "Hello World" plugin for Jenkins and I was able to upload it onto Jenkins and it works successfully. I am now trying to make change to the plugin and debug it on Jenkins.
Note:
My Jenkins is deployed in my local tomcat, i build the hpi file and copy it to jenkins plugins folder, it works.
Now i want to ask how can i debug my plugin code? Suggestions with any IDE is welcome.
I also have questions about:
do i need to create a project for jenkins source in my IDE and develop my plugin base on it?
Currently i only create a project for the plugin, build a hpi file and put it to Jenkins.
I am not sure if this step is correct.
Thanks in advance!
I imagine you ran
mvn package
to create your package
To debug you can do
mvnDebug hpi:run
and this will copy all the dependencies down (rather than in your jenkins install) and run it in place
If you are using an IDE then this can be done from within it.
More help can be found in the plugin tutorial
Follow the tutorial to set MAVEN_OPTS, and using IntelliJ to add a Jetty Server to point the port to it.
execute from cmd:
mvn clean
set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
mvn hpi:run
add a debug local Jetty Server from intelliJ and point it to port 8000 (port number is specified in above cmd)
In case of IntelliJ IDEA the easiest way is to use maven's Run/Debug configuration.
Just add hpi:run in "Command line" filed and start Debug as usual.
When the console says that your "Jenkins is fully up and running", open a browser and go to http://localhost:8080/jenkins/ and your code will stopped at break point (if any).

When deploying to Archiva from Jenkins is it necessary to change a settings.xml file where maven is concerned?

I am trying to deploy from Jenkins to Archiva. I'm not very sure how it all works. I have a maven project and I have read that I need to change a settings.xml file. I cannot find such a file in my Archiva 2.0 directories.
While in Jenkins I am using the ArtifactDeployer plugin. When I try to enter the directory from which to get the artifacts there is an error saying it does not exist.
How can I resolve this problem?
Within Jenkins, you need to register the build tools that Jenkins will use.
In regard to the buld tool Maven, I suggest:
Download, unzip, and install Apache Maven to the server on which Jenkins runs.
Configure your Maven's conf/settings.xml to point to your Archiva installation.
Configure the M2_HOME and PATH variables so that the mvn command can be executed.
Configure Jenkins to use the Apache Maven installation that you just configured.
The point is, that's a sure fire way to locate and edit a settings.xml file.
If you have Jenkins download Maven for you (I generally don't do this), then you'll have to look for a path to where Jenkins installed Maven.

Downloading Nexus artifacts to Jenkins Job workspace

I have an use case where I need to download selected jar files from nexus repository to a Jenkins job workspace and run a program over the downloaded jar files. (I Want to use the .class files in the jars)
Is there any Jenkins plugin available for this?
Add a build-step in the job, prior to the one doing the actual work
and use a copy (or ftp) command to get the files.
You could try the groovy plugin and embed a script within your Jenkins job

Intellij IDEA, build artifact using Ant?

I might be missing something, but I have been struggling with this problem for some time now.
I have an Web application with Ant build script. I would like to set up an Artifact to this module, (which is the .war file, generated using ant), so that I could deploy this war file, to the configured Tomcat server.
But I am not able to figure out, how to make Intellij use my Ant script to build artifact. I see an option to Run Ant Targets, but this just runs the Ant target and Intellij then proceeds to generate Artifact, in the usual way.
Please let me know if the question is ambiguous. The problem is not Ant Integration with Intellij. I could just use the Ant window and run any target and also could make an Ant target run as part of Build. The problem is to associate an Artifact to a module and leverage the Ant script to build that artifact. I need this to enable, tight tomcat integration, Since while integrating the Tomcat server, I can specify an artifact to be deployed.
Note: Intellij IDEA version 11.1
IDEA can either deploy Artifact or the External Source (directory or file) that is built by Ant or any other tool:
It's not possible to associate IDEA Artifact with Ant build.

Resources