How to Manage Inter-Project Dependencies using Jenkins


We have explained about Use of Jenkins and its Configuration in one of the previous blog. Here we shall discuss, how Jenkins can be used to work with inter-dependent projects. Managing the CI environment with multiple inter-dependent projects is quite important, as it is general scenario with projects.

If there are multiple projects having dependencies, then requirements would be:
  1. If Project A is dependent on Project B, then a successful build of Project B should trigger the build for Project A also. In generic words, the build of current project should trigger the build for other dependent projects also. It is required to ensure the integrity of whole project dependency chain after any change.
  2. The dependent projects should be able to pick the latest jars from Projects on which these are dependent. Different mechanism can be used for this. One of these could be to modify the build system of every dependent project to pick the required jars from downstream project
  3. This way, finally whole project chain will be built again on change in any of the project (from down to up)

Now, how we can achieve these requirements in Jenkins. Here we are describing this with an example.
  • Suppose there are three projects, Project 1, Project 2 and Project 3. 
  • Project 1 is dependent on Project 2. Project 2 is dependent on Project 3.
  • Assumption is that build of every project produce the distribute-able jar etc in a specific folder
  • Now update the 'build' for Project 3 in a way, so that before compiling its own code base, it picks the output of Project 2 build from its output folder and synchronize it in its own library folders. Of course, assumptions are to have a fixed project structure (preferably relative directory structure).
  • Similarly update the 'build' for Project 2 in a way, that before compiling its own code base, it picks the output of Project 1 'build' from its output folder and synchronize it in own library folders.
  • Create a Job in Jenkins for Project1, as described with previous article
  • Add post build actions to this job to trigger the build of Project2
  • Create a Job for Project2
  • Add post build actions to this job to trigger the build of Project 3
  • Create job for Project3
  • Using this setup, whenever Project1 will be build, it will trigger the job for Project2
  • Project 2 will pick the depdencies from Project1 output folder and will build its own code base. Build will place the output files in some specific folder.
  • Similarly Project3 build will be triggered and it will pick the dependencies from Project2 output folders

Using this approach, we shall be able to have a perfectly integrated build system and will be able to track if any of the project in whole dependency chain breaks due to any commit. On change in any project, it will trigger the build of all dependent projects. Inter-project dependencies will be synchronized automatically.

How to Set Java Home and Path in Linux

This small article will describe how to set the Java Path in Linux.

  1. Open '/etc/profile' file
  2. Add following line at the end of this file
    1. export JAVA_HOME=/usr/java/jdk1.6.0_33                                              export PATH=$PATH:/usr/java/jdk1.6.0_33/bin
    2. Change the path of JDK as per your installation
  3. This should set the path
  4. If it is not solving your problem, 
  5. Open '/etc/bashrc' file
  6. Add following line at the end of this file
    1. export JAVA_HOME=/usr/java/jdk1.6.0_33
      export PATH=$PATH:/usr/java/jdk1.6.0_33/bin
    2. Change the path of JDK as per your installation
  7. If it still does not resolve the motive,
  8. Open directory '/etc/profile.d'
  9. Create a file 'java.sh' here (if it is not there)
  10. Add following lines to this file
    1. JAVA_HOME=/usr/java/jdk1.6.0_33
      PATH=$JAVA_HOME/bin:$PATH
      export JAVA_HOME
      export PATH
Scripts located in 'profile.d' directory runs in the end and hence override any other settings done. So it should finally help to have the Java Home set in system.

How to Set Hostname for Linux Machine

Here is a small trick for defining a fix 'hostname' for linux machine. Sometimes we face a problem that 'hostname' keeps on changing for Linux machine. At first level, you can check with /etc/hosts, if settings are proper there. The contents should be like:

127.0.0.1               localhost.localdomain localhost
::1                          localhost6.localdomain6 localhost6

But sometimes, even after having these settings fine, we still face above problem.

Next level of quick fix for this problem is given below:

  • Open /etc/rc.local
  • Add following lines  in this file
  • hostname localhost.localdomain (or any other hostname if you want)
  • Save the file
  • Restart the system
This file runs in the last during network configuration (at the time of login) hence any setting which is written here will take effect finally. So whatever in your system would be affecting the hostname, will be overridden here. And you will get the right 'hostname'.

Vedic Math - Base Multiplication Part-2

Note: Vedic Math Blog has been moved to http://vedicmath.vedantatree.com/. Please bookmark the new address for new and existing blogs.

In the previous article, we learnt multiplication by taking base. We discussed following three cases:
A. Numbers are below the base number
B. Numbers are above the base number
C. One number is above the base and the other number is below it

And now, we shall discuss rest of the two cases here:
D. Numbers are not near the base number, but are near a multiple of the base number, like 20, 30, 50 , 250 , 600 etc.
E. Numbers near different bases like multiplier is near to different base and multiplicand is near to different base.

Before going further, let us take few examples of larger numbers with the same method, which we have discussed in previous article.

Example: 6848 x 9997

 6848    -3152
 9997    -0003
----------------
 6845  |  9456     (Refer to previous article for details of approach)
----------------

Example: 87654 x 99995


Let us discuss the fourth case:
D. Numbers are not near the base number, but are near a multiple of the base number, like 20, 30, 50 , 250 , 600 etc.

As you know that this method is applicable in all the cases, but works best when numbers are close to the base. Here, we shall apply the same sutras  “All from 9 and the last from 10” and "Vertically and Crosswise"  discussed earlier and also the sub sutra i.e. "Proportionately".

Take example as 207 x 213 . Here the numbers are not near to any of the bases that we used before: 10, 100, 1000 etc. But these are close to '200'. So, when neither the multiplicand nor the multiplier is near to the convenient power of 10 then we can take a convenient multiple or sub-multiple of a suitable base (as our 'Working Base'). And then perform the necessary operation by multiply or divide the result proportionately. Like in this example, we take 100 as a 'theoretical base' and take multiple of 100 i.e. 200 (100 x 2) as our 'working base'.

207 x 213
  207    +007
  213    +013
  ------------
= 220  |  091
  ------------
= (220 x 200) | 91
= 44000 + 91
44091

As they are close to 200, therefore deviations are 7 and 13 as shown above. From the usual procedure (refer to previous article), we get, 220 | 91. Now since our base is 200, we multiply the left-hand part of the answer by 200 and add it to the right-hand part. That is, (220 x200) + 91 {(Left side x base) + right side}. The final answer is '44091'.

How to Configure and Use Jenkins - A Continuous Integration System

Jenkins (http://jenkins-ci.org/) is a Continuous Integration system, facilitates continuous build and test setup for projects. It is an open source tool is similar to 'CruiseControl'. Jenkins is quite stable tool and is used by many Organizations. In this article, we shall discuss about Jenkins, its usage, and configuration.

When we call it 'Continuous Integration System', what is this?

When we work in a team environment using some Source Control / versioning tool, we checkout the work code from repository and starts working on it. After this, every developer used to commit her code to repository whenever she is finished with her work. When application is highly integrated, every commit may change the application integration scenarios, break the integration and probably can induce bugs also, or can break the code compilation etc. Now we need some tool to ensure that we check this inter-dependencies of integration and the stability of latest committed code, as soon as any body commits the code. So we need some tool, which can perform following kind of tasks:
  1. As soon as, any code is committed to source code repository (or at any given schedule), tool takes the update from repository for the project and run its build
  2. Frequency to check any new commit in source code repository should be configurable
  3. Build system is designed by team and can be based on any building mechanism like ant or maven. Tool should recognize and support the famous build tools like ant or maven etc
  4. Tool builds the project and hence all tasks configured with build system will be performed
  5. If build fails, tool should capture the 'build logs'/'console output' and should be able to send email with all logs to more than one configured email id
  6. It should have some User Interface where user can be able to see the status of various projects, their last build time, failure, logs etc
  7. If build passes, it means everything is good with new commit
  8. Then tool should be able to check if any other project or module is dependent on current project. If yes, it should trigger the build for that project also
  9. Again controls goes to step 5 for new dependent project
  10. .....
For more information about 'Continuous Integration', please refer to
  • http://en.wikipedia.org/wiki/Continuous_integration
  • http://martinfowler.com/articles/continuousIntegration.html

Jenkins support all of above features and even more with different extensions.

Earlier 'Jenkins' was known as 'Hudson'. It was started by its founder (as Hudson) developer while working with Sun Microsystem. Later, it was separated out under a separate name as 'Jenkins' due to some IP (or similar) rights conflicts. Hudson is moved to Eclipse Foundation now. You can find it at http://hudson-ci.org/

After knowing this, one question come to mind is, which tool we should use? Well, this is something everyone need to find herself. However, we have decided to go for 'Jenkins' because it is where most of the original developers and community is working. It is having quite active development releases and is going well as of now. You can find more discussions at http://stackoverflow.com/questions/4973981/how-to-choose-between-hudson-and-jenkins

How to Install Redmine 2 - A Project Management Tool

This article will describes the steps to install Redmine Version 2. Please read it in conjunction with our article about installation of previous version of Redmine at http://www.vedantatree.com/2010/12/how-to-install-redmine-project.html

Please follow these steps: 
  1. Install MySQL
  2. Download RubyInstaller and Install Ruby ( http://rubyinstaller.org/downloads/ )
  3. Download RubyGem and extract the package ( http://rubyonrails.org/download )
  4. Run 'ruby setup.rb' in RubyGem root folder
  5. Run 'gem install rails'
  6. Download MySQL dll from - http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/
  7. Save this file in <ruby-installation-folder>/bin
  8. Run 'gem install mysql'
    1. It may give you an message telling from where you can get the compatible libmysql.dll. If you get this, download it from there and put in  <ruby-installation-folder>/bin
  9. Download DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe (http://rubyinstaller.org/downloads/ )
  10. Extra it in <ruby-installation-folder>/DevKit
  11. Run following commands in DevKit folder
    1. ruby dk.rb init
    2. ruby dk.rb review
    3. ruby dk.rb install
  12. Run 'bundle install --without development test rmagick postgresql sqlite'
  13. Go to MySQL prompt and run following queries
    1. create database redmine character set utf8;
    2. create user 'redmine'@'localhost' identified by 'my_password';
    3. grant all privileges on redmine.* to 'redmine'@'localhost';
  14. Go to config folder of Redmine and update database.yml file for MySQL password
  15. Run following commands to configure the database
    1. set RAILS_ENV=production
    2. rake db:migrate
    3. rake redmine:load_default_data
  16. Now Redmine is installed. You can run the server as
    1. ruby script/rails server webrick -e production
  17. Once server is started, you can access redmine at http://localhost:3000. Default admin user name and password is: 
    1. User Name - admin
    2. Password - admin
Redmine should be working fine by now. Sometime there might be problems with various gem installations. We have covered many of these cases, like:
  • 'json' native gems requires installed build tools
  • Problem in installing rmagick
  • Problem in installing mysql gem or problem while loading data
    • activerecord-mysql-adapter not found
  • If you don't have right libmysql.dll, it may result in many errors while migrating database like
    • mysql not connected
    • Incorrect buffer type used
    • Or process gets hanged
    • and so on

For more information, please refer to http://www.redmine.org/projects/redmine/wiki/RedmineInstall .

If you like the article, you may contribute by:
  • Posting your comments which will add value to the article contents
  • Posting the article link on Social Media using the Social Media Bookmark bar
  • Connecting with 'VedantaTree' on Facebook (https://www.facebook.com/VedantaTree)

Vedic Math - Base Multiplication

Note: Vedic Math Blog has been moved to http://vedicmath.vedantatree.com/. Please bookmark the new address for new and existing blogs.

Today, we are going to learn the GENERAL formula of multiplication. This is simple and easy technique and good part is that it is applied to almost all the cases. This method works better when numbers are near their base value. After going through the below discussed method, you will see that multiplication tables are not required for calculation above 5 x 5. You will be able to do all types of multiplication involving bigger multiplicands and multipliers quickly and easily; like for '789789 × 999997'. All the sutras (formulae) of Vedic Math are short and simple; and with the practice of the techniques, most of the calculations become a playful experience for you.

Following is the sutra that we will follow today:

The formulae (sutras) are : “All from 9 and the last from 10” and "Vertically and Crosswise"
The algebraical expression is :(x+a) (x+b) = x (x+a+b) + ab.

From the title of the article, you can understand that today we shall do the multiplication by taking the base of numbers. So, first we need to be familiar what is 'base'. The term ‘base’ in Vedic Math has a broader meaning than you may be used to. We work in a base 10 number system, but within Vedic Math the ‘base’ is the number you will use as a basis for calculation. The numbers taken can be either less or more than the base considered. The difference between the number and the base is termed as deviation. Deviation may be positive or negative.

Now observe the following table.

Number      Base         Number – Base       Deviation
   13             10                  13 - 10                      3

    7              10                     7 - 10                    -3

   89             100                  89 - 100                -11

 1110           1000             1110 - 1000              110

99998          100000       99998 - 100000            -2

So, the deviation obtained are from "All from 9 and the last from 10" sutra (formula).

Following are the cases which we shall discuss here:
A. Numbers are below the base number
B. Numbers are above the base number
C. One number is above the base and the other number is below it
D. Numbers are not near the base number, but are near a multiple of the base number, like 20, 30, 50 , 250 , 600 etc
E. Numbers near different bases like multiplier is near to different base and multiplicand is near to different base

Let us discuss these cases one by one.

A. Numbers are below the base number

Working with Base 10
Let us take an easy and simple example to start this technique. Suppose we have to multiply 6 by 8.
Now the base is 10. Since it is near to both the numbers.
Place the two numbers 6 and 8 above and below on the lefthand side (as shown below). Subtract the base value (i.e. 10 in this case) from both of the numbers and write down the remainders (i.e. 4 and 2) on the right-hand side with their deviation sign (-).

6 x 8   

Redmine Java Connector 1.0.0 Released

We are happy to announce the second release of Redmine Java Connector (RedmineJConnector) at http://code.google.com/p/redmine-jconnector/. It is a Java based client side API for Redmine.

The product was born out of necessity. We were desperate for a Java based Redmine Client library which can help us to interact with Redmine from our projects. However we were not able to find any library matching to such requirements at that time. So this product is the result of this requirement, and now we are using it with our projects also.

RedmineJConnector is capable to interact with Redmine Server (http://redmine.org/) using its Rest API. Redmine provides API for various CRUD operations on its main data objects like Projects, Issues, Users etc. RedmineJConnector helps to perform these CRUD operations using exposed Rest API without going into intricacies of Rest Service interaction.

Features released with 1.0.0 version are: 
  1. Get all Projects and Issues
    1. It is supported with Data Paginator feature. It is an 'iterator' based implementation. 
    2. This feature will facilitate the user to fetch all data objects from Redmine in specific size pages. 
    3. It should help in memory and performance management, which may get critical in case if we fetch all objects in one go. 
  2. Improved Exception Handling
  3. Improved Java Doc
  4. Improved build with inclusion of Java Doc generation and JUnit Test cases
  5. JUnit test cases for all new implementation

Improve Productivity with these Desktop and Mobile Tools


Productivity, improvement in efficiency is quite a hot mantra nowadays to be successful and to achieve the growing number of goals. With the fast moving life, demanding expectations, people are in continuous pressure to improve what they are doing now, to manage multiple tasks simultaneously, and to remember many things which they need to complete in a day or probably in few days. Won't you feel, sometime our mind gets exhausted with this sea of information and tasks. However, to meet the expectations, we have to manage it. Managing information, planning ahead, scheduling, remembering the schedule and then execute it, is the key to success. But one point is certainly clear that we need some help to manage this bulk information and tasks etc. So how should we do that? Are we talking about having a personal secretary.. sort of :). But everyone can not afford to hire a personnel for this management. So.....

Alternative good solution, in this high tech world, is to use available productivity and hobbies related tools on mobile phone and desktop computers. There are many good tools available on phones and in browsers which can actually help us to manage our day, to manage our task list, schedules, alarms, goals and can keep us updated for all information which we want. Now the need is to identify these and utilize these properly. We have explored and used few tools as need arises, which we are sharing here if these can help. These are very simple tools and many people must be using these. These can give a good start to the beginners.

Let us start from desktop. On desktop if you are using or can use Chrome Browser, following tools can definitely help you. These are:

Google Calendar: It helps you to schedule your events. Events can be one time, or recurring. It has good facility to schedule as per requirements. Moreover, there are various ways to remind you for these events like

  1. It can send you email before any pre-defined interval. It can actually send multiple mails at multiple time gaps.
  2. It can send you the daily agenda as per your calendar event schedule
  3. It can send you SMS on your register phone number
  4. It can show you alert on your computer screen, if Google calendar is opened in browser

Isn't that great to have reminders for all of your events beforehand, and moreover, you can define the reminder's frequency and style. That is actually like having a personal assistant, who reminds you for every event you want to be reminded for. You can access it anywhere anytime, even on your mobile wherever you are.

Vedic Math - Mathematical magic trick

Note: Vedic Math Blog has been moved to http://vedicmath.vedantatree.com/. Please bookmark the new address for new and existing blogs.

Let us take a break from calculations and enjoy a small magical mathematics trick.

1. Think a number (any number). To keep it easy, think any number having 1 or 2 digit.
2. Now double this number i.e. multiple by 2.
3. Add 12 to the result
4. Divide the total by 2.
5. Subtract the original number from above result.
6. And you will always get '6' as final result.

Try this one with different numbers, and you will see that the sequence always produces the '6' as result ,no matter which number was originally selected.

For example, if the original number is 15.
1. 2 x 15 = 30
2. 30 + 12 = 42
3. 42 / 2 = 21
4. 21 - 15 = 6

You must be curious that how this magic trick is working. Following is the concept for this magic trick:

Let us take a number be x and the steps performed by us are:
1. 2x
2. 2x + 12
3.(2x + 12) / 2 = x + 6
4. x + 6 - x = 6

So, in last step, we see that whatever number we choose (as x) will finally result in '6' with above calculation. After knowing the formula, now you can change the answer by changing the formula. For example, if you want to change the answer to '4', then you add twice of that '4' i.e. '8' in the second step.

Enjoy this trick!!