Showing posts with label Jenkins. Show all posts
Showing posts with label Jenkins. Show all posts

October 20, 2014

JENKINS ISSUE: Illegal Argument exception

This article talks about Illegal Argument Exception occuring in Jenkins v1.559 during build time.

After migrating from SVN to Git, java.lang.IllegalArgumentException started to occur atleast couple of times a week on daily build, while checking out the source code. Re-starting the Jenkins Slave on the build server, helped us to go past the issue temporarily and root cause exploration continued.

Earlier the assumtions & focus was to rule out options around issues with Git installation / configuration but later narrowed down that the incorrect version of Jenkins Slave installed was the causing IllegalArgumentException.

Solution:
Updating the Jenkins slave from v2.2.x to  2.37 resolved the issue.

January 28, 2014

Authentication Token is required to trigger the Jenkins Jobs Remotely

This article focuses on triggering the Jenkins Job remotely in 1.499 and the issue faced when upgraded to 1.546.

With Jenkins 1.499, GET method was used to invoke the URL http://JenkinsURL/job/JOBNAME/buildWithParameters?param1=value1&param2=value2

With the latest version of Jenkins (say 1.546), the trouble started while triggering the Jenkins jobs remotely as Jenkins is looking for POST rather than GET method and giving below error message,


Further research fetched some light through the below  URL that an authentication token that needs to be passed to the Jenkins job as shown in the below screen shot and it has helped to resolve the issue.


 
So the updated URL with Authentication Token for POST method is  http://JenkinsURL/job/JOBNAME/buildWithParameters?param1=value1&param2=value2&token=build

January 15, 2014

Multijob Plugin throws NoClassDefFoundError without Parameter Plugin

If you install a multi-job plugin 1.7 on Jenkins 1.499 without Parameter plugin, you will get NoClassDefFoundError (as mentioned below), while creating a multi-job and saving it.

So while installing any plugin, make sure to install all the required dependant plugins.

Status Code: 500

Exception: java.lang.NoClassDefFoundError: hudson/plugins/parameterizedtrigger/AbstractBuildParameters$DontTriggerException
Stacktrace:

javax.servlet.ServletException: java.lang.NoClassDefFoundError: hudson/plugins/parameterizedtrigger/AbstractBuildParameters$DontTriggerException

        at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:615)
        at org.kohsuke.stapler.Stapler.invoke(Stapler.java:658)
        at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:241)
        at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
        at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:573)
        at org.kohsuke.stapler.Stapler.invoke(Stapler.java:658)
        at org.kohsuke.stapler.Stapler.invoke(Stapler.java:487)
        at org.kohsuke.stapler.Stapler.service(Stapler.java:164)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:45)
        at winstone.ServletConfiguration.execute(ServletConfiguration.java:248)
        at winstone.RequestDispatcher.forward(RequestDispatcher.java:333)
        at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:376)
        at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:95)
        at hudson.plugins.greenballs.GreenBallFilter.doFilter(GreenBallFilter.java:58)
        at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:98)
        at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:87)
        at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
        at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
        at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:47)
        at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
        at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
        at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
        at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
        at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
        at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
        at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
        at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:50)
        at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
        at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
        at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
        at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
        at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
        at winstone.RequestDispatcher.forward(RequestDispatcher.java:331)
        at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:215)
        at winstone.RequestHandlerThread.run(RequestHandlerThread.java:138)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: hudson/plugins/parameterizedtrigger/AbstractBuildParameters$DontTriggerException
        at java.lang.Class.getDeclaredFields0(Native Method)
        at java.lang.Class.privateGetDeclaredFields(Unknown Source)
        at java.lang.Class.privateGetPublicFields(Unknown Source)
        at java.lang.Class.getFields(Unknown Source)
        at org.kohsuke.stapler.ClassDescriptor.<init>(ClassDescriptor.java:71)
        at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:561)
        at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:618)
        at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:377)
        at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:574)
        at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:377)
        at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:373)
        at com.tikal.jenkins.plugins.multijob.MultiJobBuilder$DescriptorImpl.newInstance(MultiJobBuilder.java:231)
        at com.tikal.jenkins.plugins.multijob.MultiJobBuilder$DescriptorImpl.newInstance(MultiJobBuilder.java:214)
        at hudson.model.Descriptor.newInstancesFromHeteroList(Descriptor.java:939)
        at hudson.model.Descriptor.newInstancesFromHeteroList(Descriptor.java:926)
        at hudson.util.DescribableList.rebuildHetero(DescribableList.java:203)
        at hudson.model.Project.submit(Project.java:200)
        at hudson.model.Job.doConfigSubmit(Job.java:1046)
        at hudson.model.AbstractProject.doConfigSubmit(AbstractProject.java:723)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:288)
        at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:151)
        at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:90)
        at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111)
        at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
        at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:573)
        ... 41 more

Caused by: java.lang.ClassNotFoundException: hudson.plugins.parameterizedtrigger.AbstractBuildParameters$DontTriggerException
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 70 more

Related Article: Multijob Plugin Null Pointer Exception.
 

July 18, 2013

Custom Logo for Jenkins

For having your custom or company specific logo for Jenkins Instance, follow the steps below
  1. Create a custom image or logo of your choice in png format (refer title.png under <Jenkins_Install_Directory>/war/images for size specification.
  2. Replace <Jenkins_Install_Directory>/war/images/title.png with the custom image and your Jenkins Instance is all set with new look (i.e with Custom Image).

April 24, 2013

Jenkins Multijob Plugin - Missing Slashes while traversing down

This article talks about the Missing Slashes (\\) while traversing from high-level to low-level jobs in a Jenkins Multijob project.

Lets assume a scenario where we have two free style jobs (low-level) jobA and jobB, which copies a set of files from Source to Destination path. And a Parent job (Multijob) parentA which calls jobA and jobB with Source and Destination path as parameter.

While passing Source and Destination dir from parentA to jobA and jobB, two slashes gets stripped off due to the Jenkins regular expression behaviour.

Input Entered for parentA:
Source: \\\\serverone\\\\pathone
Destination: d:\\\\temp\\\\testdir

As Received in jobA and jobB:
Source: \\serverone\\pathone
Destination: d:\\temp\\testdir

Here is the pictorial representation of our discussion..

For every higher level you add before parentA, multiply the number of slashes in that particular level by 2.
grantparentA -> parentA -> jobA   =>   8 -> 4 -> 2

You might wonder that we may have to add 8 slashes for the UNC Path (Source: \\\\serverone\\\\pathone) but your jenkins does not work if you do so. To explain further about UNC Path => When we supply 4 slashes to the parent job, child job will get value  \\serverone\pathone  not \\serverone\\pathone (which Jenkins expects).
Hence we are using 4 slashes from parent jobs instead of 8.

April 2, 2013

Jenkins - Multijob Plugin - Null Pointer Exception

Jenkins Multijob plugins comes handy when you wanted to run some set of jobs in parallel or a combination of sequential or parallel.
Here is a small discussion around the Null Pointer Exception with Multijob Plugin and the fix for the same.

Environment Details:
Jenkins 1.499
Multijob Plugin version 1.7 (parameterized-trigger.jpi is mandatory for Multijob plugin)

Problem Statement:
We have 3 defined using Multijob plugin as follows
 Multijob_Parent
         Multijob_1A
         Multijob_1B

When you run the top level job (sayMultijob_Parent), sometimes the following issue occurs

C:\Program Files (x86)\Jenkins\jobs\MultiJob_Parent\workspace>exit 0
Starting build job MultiJob_1A.
Starting build job  MultiJob_1B.
Finished Build :  #34 of Job :  MultiJob_1A with status :SUCCESS
Finished Build : #23 of Job :  MultiJob_1B with status :SUCCESS
FATAL: null
java.lang.NullPointerException
        at com.tikal.jenkins.plugins.multijob.MultiJobBuild$MultiJobRunnerImpl.evaluateResult(MultiJobBuild.java:69)
        at com.tikal.jenkins.plugins.multijob.MultiJobBuild$MultiJobRunnerImpl.isFailure(MultiJobBuild.java:59)
        at com.tikal.jenkins.plugins.multijob.MultiJobBuild$MultiJobRunnerImpl.run(MultiJobBuild.java:51)
        at hudson.model.Run.execute(Run.java:1543)
        at hudson.model.Run.run(Run.java:1489)
        at com.tikal.jenkins.plugins.multijob.MultiJobBuild.run(MultiJobBuild.java:43)
        at hudson.model.ResourceController.execute(ResourceController.java:88)
        at hudson.model.Executor.run(Executor.java:236)

In this example, both Multijob_1A & Multijob_1B have succeeded but Multijob_Parent have failed with null pointer exception.
Assume a senario where you have 3 levels of jobs, sometimes failure in 3rd level, might have prevented some jobs to start, which is even more dangerous.                        

Solution:

Here is the fix - https://issues.jenkins-ci.org/browse/JENKINS-16042, provided by authors and follow the below steps to upgrade the Multijob Plugin.

Steps to upgrade the Multijob Plugin:
  1. Upload hpi suggested in the above link.
  2. Click "Install without restart" button
  3. Go to Manage jenkins -> Manage Plugin -> Installed -> uninstall the multijob plugin.
  4. Go to Manage jenkins - Click "Prepare for shutdown"
  5. Stop Jenkins Service
  6. Start Jenkins Service
  7. View the plugin version under installed plugin - should be updated to snapshot version by now
  8. Verify that the multijobs are in place.

March 30, 2013

Jenkins - Running a common task on Multiple Agents

Sometimes we may want to run similar set of tasks on a list of computers. Jenkins Multi-Configuration Projects will help you to achive this.

Assume a scenario where you wanted to configure.bat on the computers PC1A, PC2A, PC3A and PC4A.

Steps:
  1. Jenkins - New Job ->Enter a name "ConfigureAll", Select "Build multi-configuration project" radio button and click "OK"
  2. Go to Configuration Matrix in ConfigureAll job, Select Slaves drop down from "Add Axis" drop down
  3. Node/Label filed will list all the nodes that are added to the Jenkis Server.
  4. Select the nodes PC1A, PC2A, PC3A and PC4A.
  5. Add a Build Step to "Execute Windows batch command" and enter <path>\configure.bat.
With this approach, you can have one job to perform a common action on n slave agents.

February 10, 2013

Jenkins - Uninstallation Server & Slave

 Here is the straight forwards steps to uninstall Jenkins Server and Slave software from the machine.

Jenkins Server uninstallation:

  •  Go to Add / Remove programs and remove Jenkins (Major.MinorVersion). 

Jenkins Slave uninstallation:

  1. Login to the machine where Jenkins Slave is installled and run “sc delete jenkinsslave-D__Software_jenkinsslave” from command prompt to delete the Jenkins Slave service.
  2. Restart the machine and verify that the Jenkins Slave Windows Service is deleted.
  3. Delete D:\Software\jenkinsslave on the Jenkins Slave machine.
The above Slave uninstallation steps comes handy to remove the current instance completely in case of any issues.

Refer here for Jenkins - Installation & Configuration.

February 8, 2013

Jenkins - Installation & Configuration


This article focus on the steps involved in setting up Jenkins Server and Slave on Windows Operating system using Windows native Package.

Jenkins Server Installation:
  1. Download Windows native Package here.
  2. Extract and run the setup.exe on your proposed Jenkin Server Machine.
  3. URL -> http://JenkinsServerURL:8080/ will be launched at the end of installation and a Windows Service named "Jenkins" will be created (verify the same from Services.msc).
  4. Go to Manage Jenkins -> Manage Plugin -> Available Tab and download and install the required plugins. The following list gives you the basic list of plugins where you need to have multiple nodes, multiple jobs - some to be run parallelly and / or sequentially
·         Dashboard viewBuild Pipeline Plugin
·         Jenkins descriptor setter plugin
·         Green Balls
·         Jenkins Multijob Plugin
·         Jenkins Promoted Build Plugin
·         Jenkins Parameterized Trigger plugin (this is mandatory for Jenkins Multijob Plugin)
·         Mask Passwords Plugin
·         build-name-setter
·         Token Macro Plugin
·         Node and Label Parameter Plugin
·         Log Parser plugin
·         Jenkins Workspace Cleanup Plugin
·         Jenkins Email Extension Plugin

5.   Changing the http port number -> Edit <Jenkins InstallDir>\Jenkins.xml to set the httpport as 80, Save and retart Jenkins Server.

6.   If you do not have internet access in the Jenkins Server, Download the Plugins on your local box and upload to Jekins Server by browsing through the URL.

Go to Manage Jenkins -> Manage Plugin -> Advanced -> and browse to the plugin that needs to be uploaded. 

Click Install without restart to install the plugin (You can restart the Jenkins Windows Service if required).
 

Jenkins Server Configuration:

1.   Go to Manage Jenkins -> Configure System and update Jeinkins Location• example - Jenkins URL - http://JenkinsServerURL/ and provide System Admin e-mail address.

2.   Go to Manage Jenkins -> Configure Global Security and select "Enable Security" checkbox

·         Choose Fixed for TCP port for JNLP slave agents and set its value to 18000 (a random number)

·         By default Authorization mode is "Anyone can do anything" and you can change on need basis.

3.   Open two ports HTTP (80/tcp) and 18000/tcp for all the Jenkins Agents to access the Server via these Ports.

4.   Go to Manage Jenkins -> Manage Node to Add, Remove and Monitor Nodes. Add a Node and set the “Remote FS root” pointing to “JenkinsSlave Installation Directory” on Node

Jenkins Slave Installation:

1.     Prepare Semi-automated installations for Jenkin Slave
·         Login in to Jenkins Server machine
·         Copy jre folder & its content from Jenkins Server installation directory to D:\Jenkins_Slave.
·         Create a file named InstallJenkinSlave.bat under D:\Jenkins_Slave and copy the following
set JRE_PATH=d:\software\jre_jenkins\bin

xcopy /E /I \\jenkinsserver\d$\Jenkins_Slave\jre d:\software\jre_jenkins

:: Setting System wide Path for Jenkins JRE
setx path "%JRE_PATH%;%path%" /m


2. Install Jenkins Slave
·         Login into proposed Jenkins Slave installation machine.
·         Run \\jenkinsserver\d$\Jenkins_Slave\InstallJenkinSlave.bat from the command prompt
·         You will get the below application launched.
 
·         Click "Install as a service" to proceed.
·         Click "OK" in the message box "This will install a slave agent as a Windows service, so that a Jenkins slave starts automatically when the machine boots. When the installation is over, this slave agent will exit to let the new service take over."
·         You will get the error as “WMI.WmiException: StatusServiceExists", if service is already installed. Otherwise the installation proceeds without any error.
·         This completes Jenkins Slave Installation and a Windows Service named "Jenkins Slave" will be created