Tuesday, 27 August 2013

Jenkins Master/Slave Configuration.


Jenkins Master/Slave Configuration.

Taking our jenkins setup in concern.

We have a Jenkins instance installed on a Ubuntu 10.04 LTS machine. This machine is good enough to build Android projects through Ant build script. But  in order to build iOS Application and Windows application where the build has dependencies with the OS. We cannot build these application on our Linux
i.e we need to have a Mac and Windows machines resp to build their application.

So we would need to have separate slave machines which will help the master machine to build specific tied projects at their end.

To configure the master/slave configuration.

1. Create a new node
Home page->Manage Jenkins->Manage Nodes->New Node
New node configuration:
a. enter name
b. select dump slave and click ok.
c. enter slave name
d. enter number of executors on the slave machine.
e. usage : for ties jobs.
f. Launch method : Java web start.
g. Availibility : online as much as possible.

Now on the home page you will see a new node with the given name at the left side pane with a offline symbol. Now that you have a new node, all you need to do is to connect this new node.

2. Connect the slave machie :
a. Go to the slave machine for example a Mac if you want to make slave machine for building iOS apps.
b. open the jenkins in browser.
c. click on the new node that is showing offline.
d. Click on the "Launch" java web start icon.
NOTE: Initially you would get error as the .jnlp file you have downloaded doesn't contain the correct jenkins server instance path. So you would need to edit it and then again run it by double clicking the file.
e. It will open up a little popup showing "connected" text.
f. After the slave has been connected you could actually see the slave machine online which was showing offline with the defined number of executors you set in its configuration.
g. in windows machine you could also install this java application as a service so that in case of a reboot of windows slave machine the slave can run this application and again connect itself.
h. to install as service just go to the java web application: file->install as service.
and you are done. To double check do to start->services->search "jenkins" -> openup the service and configure it if required.
Double check the connect mode is set to automatic.

3. Jobs Configuration to run on the slave:
As our slave machines are configured to run only tied jobs. Now we need to specifically tie to jobs to always execute on the slave machines. For that.
a. create a new job or go to the configuration page of a existing job
b. Below the description section there is a check box saying "Restrict where this project can be run". So check it and enter the name of the slave machine where the job should run.
c. click save.
From now onwards the job will be executed on the slave machine.


That's it!!

Review board windows client setup

After once we have successfully setup a review board server(which is not part of this post) we need to setup our client machine to be able to create diffs and upload it onto the review board server for review.

Here i am covering how to setup windows client developer machine

1. Install Python2.7.3 : download form here - http://www.python.org/download/releases/2.7.3/

Reviewboard doesn't support 3.x versions of python to work properly.

2. Install python setuptools:
a. goto - https://pypi.python.org/pypi/setuptools/1.1#installation-instructions
b. search for "ez_setup.py"
c. right click and save the file.
d. run this script. It is suppose to download and install the proper version of the setuptools.

Note: You may run in a situation where the script could fail due to lack of administrator permissions.
And you would not get a option to run the script as admin. To enable that you would need to do certain registry tweaks manually. Follow the link - http://www.howtogeek.com/howto/windows-vista/add-run-as-administrator-to-any-file-type-in-windows-vista/

e. after successful installation you could see easy_install.exe under the C:\Python27\Scripts location.
f. add "C:\Python27" and "C:\Python27\Scripts" for easy access.

3. Install RBTools:
a. open command prompt
b. type = easy_install -U RBTools
c. It will install the RBTools for you.

Usage:

a. Checkout the code.
b. create a .reviewboardrc file and add line  - REVIEWBOARD_URL = 'http://reviewboardpath.com' 
c. type post-review - it should create the diff and upload it to the review board server now.

NOTE: If you see a error like "The current directory does not contain a checkout from a supported source code repository". Then in windows one of the most common cause would be that you dont have command line svn installed. It looks like post-review cannot communicate to the svn server through TortoiseSVN.

 

Monday, 19 August 2013

JavaScript Data Types.

Learning JavaScript is not a bad idea as this language is the future or both web and windows applications. Lets start by looking at the data types in a nutshell.

JavaScript has the following data types:

1. Numbers
2. Strings
3. Boolean
4. Arrays
5. Object
6. null
7. undefined

Lets talk about them briefly.

1. Numbers - There is only one number type, i.e there is no separate integer, float etc.
This number is a 64-bit floating point. Which is also called IEEE-754(aka "Double").

There is a special value called NaN(Not a Number)
a. It is a result of undefined or erroneous operation. e.g divide something by zero results in NaN.
b. Toxic: any arithmetic operation with NAN as input will result NaN as output.
c. NaN is not equal to anything including NaN. i.e NaN ==NaN is false NaN is not lesser or greater then NaN :). Even when NaN is not a number but its data type is a Number.

Functions to convert string into numbers.
  •  Number(value):
It converts the value into a number.
It results NaN if it has a problem.
Similar to '+' prefix operator

  • parseInt(value, 10) e.g parseInt("55", 10)
  • + prefix operator. e.g +"55"

2. Strings: It is a sequence of  0 or more 16-bit characters.
There is no separate Character type. i.e characters are represented as strings with length 1.
Strings are Immutable.
Similar Strings are equal ( == )
String literal can use single or double quotes.
String is a object and it has lot of methods to perform on strings i.e
a. charAt
b. concat
c. match ....etc

3. Boolean:  There are two values true or false.
There is a Boolean function i.e Boolean(value) which returns true if the value is truthy and false if its falsy
It is similar to !! prefix operator.

Falsy values:
  • false
  • null
  • undefined
  • "" (empty string)
  • 0
  • NaN
Truthy Values: All other values including objects are truthy. "0" ,"false" are also truthy. They are strings.

4. null - A value that isn't anything.

5. undefined :
a.  It is the default value for a variable. i.e if you declare a variable but don't initialize it. Then its value will be undefined.

6. Object: 
  1. Its a unification of objects and hash-table.
  2. new object() produces an empty container of  name-value pairs.
  3. A name can be any string, and a value can be any value except undefined
  4. Members can be accessed with dot notation. 
  5. An object is delimited by curly braces. Inside these braces we define the object's properties in the form of key value pairs.
Object is defined like:
var person={firstname:"Jai", lastname:"Pandit", id:5566};
or
var person = new object()
// now add properties to the object.
person.firstname = "Jai"
person.lastname = "Pandit"
person.id = "5566"

7. Arrays :

The following code creates an Array called cars:
var cars=new Array();
cars[0]="Saab";
cars[1]="Volvo";
cars[2]="BMW";
or (condensed array):
var cars=new Array("Saab","Volvo","BMW");