Monthly Archives: April 2015

Integrating Jenkins (Debian) with BitBucket

The Jenkins CI server can be integrated with BitBucket by using the concept of deployment keys. In BitBucket go to Settings > Deployment Keys. Add a new public key. Make sure you are adding an openssh compatible public key otherwise the key won’t be accepted. Once this is done you need to test the read-only cloning capability using this approach.

ssh-agent (ssh-add /home/user1/ssh_keys/my_private_key; git clone git@bitbucket.org:my_user/my_project.git)

This command basically attempts to make a clone from the BitBucket server using the private key you specified as ‘my_private_key’. Since we are using the ssh-agent command to wrap the other two commands the key is loaded, the clone command is executed and then immediately the key is unloaded. If your cloning process failed you know that something is wrong. Remember you need the private key in openssh format as well.

If the above command gave you the cloned repository, go ahead and use this private key inside the Jenkins server.

Please do refer to BitBucket documentation link has more details on the exact steps.

Jenkins Configuration Issue

I was trying to setup Jenkins web app inside the Tomcat server and it continuously gave me this error:

SEVERE: Failed to initialize Jenkins
hudson.util.NoHomeDir

This I fixed by creating the folder ‘/usr/share/tomcat7/.jenkins’

mkdir /usr/share/tomcat7/.jenkins

On redeploying Jenkins I again noticed the following error.

WARNING: Failed to record boot attempts
java.io.FileNotFoundException: /usr/share/tomcat7/.jenkins/failed-boot-attempts.txt (Permission denied)

I fixed this issue by giving full access to this folder.

sudo chmod 777 /usr/share/tomcat7/.jenkins

I believe 777 is not a good approach in a production environment, but for development perspective it looks ok.

Completely removing packages in Debian Linux

I recently had to find out if a particular package was properly installed in my Debian Linux OS as something was broken. I used the following command to do that.

dpkg --get-selections | grep -v deinstall | grep oracle

This basically lists out all the packages which contain the text ‘oracle’ in them. Once I find out the exact package name I can actually decide to remove all packages containing them.

sudo apt-get purge oracle*
sudo apt-get autoremove oracle*