install jenkins with java thats in a specifed folder - jenkins

I want to update jenkins(currently using jdk 6;to upgrade jenkins i need jdk7) but so, many application in my jenkins server use jdk6.So, I cannot update java.So, I want to copy java binary in folder like /home/username/java and I want to make jenkins use /home/username/java while updating.So, the other programs don't get disturbed(Most of them use which java and get the java installation example:maven and some other tools I am not aware of).Is there a config file which can be edited to make jenkins use a java in a specific folder(while installing or updating).

There is a JDK dropdown in "job name" -> Configure in Jenkins web UI. It will list all JDKs available in Jenkins configuration.
You can add new JDKs through Manage Jenkins -> Global Tool Configuration -> JDK.
Here is a visual of where you should configure additional JDKs in Jenkins:

Related

Compilation error while running maven project via jenkins [duplicate]

I'm getting this error when I try a Jenkins build on a maven project:
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
The java and maven plugin are installed automatically, after several research, I couldn't find a solution!
Does anyone have ever face this issue?
Go To Jenkins -> Manage Jenkins -> Global Tool Configuration -> JDK. Provide path to the JDK under JAVA_HOME field.
First make sure the your Job in Jenkins doesn't use the "default Jdk" by going to the job:
Press on Configure - > and roll to the JDK section - and make sure you have JDK configure instead of Default.
if you don't have it - go back to Jenkins - > Manage Jenkins -> Configure System - > Jdk and map your Jdk Root for Jenkins.
when you finish that - go back and choose your map JDK - and everything will work.
Go To Jenkins -> Manage Jenkins -> Global Tool Configuration.
Now click on "JDK installations.." under JDK
Uncheck Install automatically
Provide path to the JDK under JAVA_HOME field.
Refer:-
May be this issue is already resolved by now. But I had the same issue recently and I have the following settings in my Jenkins. This happened in my Windows 10 Jenkins installation.
Installed JDK at C:\Java\Jdk8 and made JAVA_HOME point to this location. Also make sure that PATH env variable has %JAVA_HOME%\bin.
Installed JRE (which comes bundled with Oracle JDK installation) at C:\Program Files\Java\JRE.
Jenkins -> Manage Jenkins -> Configure System
Jenkins -> Manage Jenkins -> Global Tool Configuration
# javac -version
javac 1.8.0_201
# java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
# mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T14:41:47-04:00)
Maven home: C:\apache-maven-3.6.0\bin\..
Java version: 1.8.0_201, vendor: Oracle Corporation, runtime: C:\Java\jdk8\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
I believe the change that fixed the problem was the addition of env variables under Manage Jenkins -> Configure System.
Enter http://localhost:8080/configure. Then go Jenkins Location.
Jenkins Configuration:
Environment variable configuration:
You might not have set JAVA_HOME in Jenkin installed server. Set JAVA_HOME and restart your Jenkin server.
According to your error message you either do not have a JDK installed or you need to configure Jenkins's CLASSPATH to point to your JDK installation.
Just give the JDK path in Jenkins Global Tool configurations, i.e the path where we have kept the jdk file in the di
IF you don't want to add anythig in Global tools Configuration, add new environment variable java.home in the Jenkins slave configuration as maven detects java.home and not JAVA_HOME.
java.home ---> C:\Java\jdk1.8.0_181\jre

Not able to see "Invoke ANT" option on Jenkins 2.85

I am using Jenkins version 2.85 and trying to invoke or add ANT plugin. However, I can't see "Invoke ANT" option under Global Tool Configuration.
I have configured ANT and verified the version as follows.
Apache Ant(TM) version 1.10.1 compiled on February 2 2017
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed
Kindly let me know how can I get "Invoke ANT" option.
Thanks,
Narasimha
You probably need to install Jenkins ANT plugin for that.
Install Ant Plugin by going to Manage Jenkins -> Manage Plugins -> Available Tab and search for Ant and install all the relevant ant plugin.
Configure ant plugin by going to Manage Jenkins -> Global Tool Configuration.
You'll see an option Ant, either install Ant if you don't have on the local system or if you have ant configured on your local system, directly provide the ANT_HOME.

Missing Ant Global Tool Configuration in Jenkins

Why doesn't the Ant Configuration in my Jenkins appear under Global Tool Configuration?
See the image below:
There are only tabs for JDK and Maven.
In the other references I checked, there are others like Git and Ant, etc.
Make sure that the Ant Plugin is installed in your Jenkins instance. Go to Manage Jenkins -> Manage Plugins and search for the plugin there under the Available tab.

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.

Resources