Tuesday, September 13, 2016

Set up Jenkins Slave (on Linux)

1        Create a jenkins user on the Slave

Create a jenkins user and a password using the following command on the slave server [your_slave_server]

sudo adduser jenkins --shell /bin/bash
sudo passwd jenkins

By default this creates user jenkins at /home/jenkins
Now login as user jenkins and create a slave directory under jenkins.

mkdir ~/slave

2       Setting up Slaves jenkins on the Master Using Username and Password

Click on the New Node, then give it a name, select the “Permanent Agent” option and click ok.

In the New Node Page, Click Add button besides Credentials field to create the credential, which is the jenkins user and password to the slave server. The password is encrypted in the jenkins system.

Enter the values as indicated below. Then click save

Once saved, Jenkins will automatically connect to the slave machine and configure an agent. Noticeably, slave.jar will be install in /home/jenkins/slave on the slave server and eventually workspace will be created there too.

3        Setting up a Slave jenkins using ssh Key

This is the preferred method as the access is not tied with the user’s password and there won’t be impact if the user’s password is changed.

1.       Login to the slave server as a jenkins user
2.       Create an .ssh directory and cd into the directory

mkdir ~/.ssh
chmod 700 ~/.ssh
cd ~/.ssh

The .ssh directory must have proper access permissions that group and others cannot have write permissions, otherwise, the following error would show when starting the slave.
ERROR: Server rejected the 1 private key(s) for jenkins (credentialId:***/method:publickey)

3.       Create an ssh key pair using the following command. Press enter for all the defaults when prompted

ssh-keygen -t rsa -C "The access key for You Jenkins slave"

4.       Add the public to authorized_keys file using the following command.

cat id_rsa.pub > ~/.ssh/authorized_keys

5.       Copy the contents of the private key in id_rsa to the clipboard.

cat id_rsa

6.       Login in to Jenkins Web Console as an administrator
Go to dashboard –> credentials –> Global credentials –> add credentials 

Select SSH Username with private key 
Enter jenkins as the username
Paste the key in the clipboard to Private Key (Enter directly)
click ok.

7.       Go to Dashboard –> Manage Jenkins –> Manage Nodes
Select the key credential for the Slave configuration then click Save.

Friday, December 26, 2014

Is it possible to handle conflicts between 2 versions of jQuery loaded in the same page?

Question: Is it possible to handle conflicts between 2 versions of jQuery loaded in the same page?

Answer:  Using jQuery.noConflict, you can make multiple versions of jQuery coexist on the same page.
<!-- load jQuery 1.1.3 -->
<script type="text/javascript" src="http://example.com/jquery-1.1.3.js"></script>
<script type="text/javascript">
var jQuery_1_1_3 = $.noConflict(true);

<!-- load jQuery 1.3.2 -->
<script type="text/javascript" src="http://example.com/jquery-1.3.2.js"></script>
<script type="text/javascript">
var jQuery_1_3_2 = $.noConflict(true);
Then, instead of $('#selector').function();, you'd do jQuery_1_3_2('#selector').function(); or jQuery_1_1_3('#selector').function();.

Thursday, December 18, 2014

Why the space is not freed on UNIX after a file is deleted?

Question: When a large file is deleted from a UNIX file system why is the free space not changing?

Answer: One possibility is that the file being deleted have more references in the filesystem, such as it is still open by a user, in this case the space will be freed after the file is closed.