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.

March 17, 2013

Silent install / uninstall command for Slik SVN 1.7.8


The following post discusses about the Silent installation / uninstallation command for Slik SVN 1.7.8m - 64-bit installer and the same applies to 32-bit installer as well.

Installation:
               msiexec /i "Slik-Subversion-1.7.8-x64.msi" /qn /norestart INSTALLLOCATION="D:\Software\SlikSVN" /l* "svninstall.log"
                      /qa -> optional parameter to run the installer in silent mode
                        INSTALLLOCATION -> Custom Installation directory
                        /l* "svninstall.log" -> optional parameter for logging the installation to svninstall.log

Uninstallation:              
·         Silent Uninstall command with Product Code:
                msiexec /x {D0BD7396-3187-48FE-8327-C27385275D18}

·         Silent Uninstall command with installer name:
                msiexec /x "Slik-Subversion-1.7.8-x64.msi"

 
For locked down environments like Vista, Windows 7 & Windows Server 2008 (when UAC is turned ON), do the following

·         Launch the command prompt with elevated privileges (i.e. Right Click cmd.exe and say “Run as administrator”), otherwise the installer will fail.

·         If you get the following error message while running msiexec from the command prompt, append “C:\Windows\System32” to the PATH variable
                                'msiexec' is not recognized as an internal or external command,
                                operable program or batch file.

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.