Tuesday, March 20, 2012

Jenkins + git + Heroku on mac

To automate the deployment and testing of my brand new Heroku backed Django app, I wanted to setup a Jenkings CI system on my home macmini.

That was not wuite as easy as I has thought it was.

Getting it running was easy, just use the installer. And there is a git plugin, sweet. But getting that to work was a pain.

When ever I tried to fetch the project for heroku git repo, I would end up with weird errors. For some reason Jenkins wanted to read .ssh keys from /etc/root, write Heroku credentials to my own home directory etc.

After poking around a bit I found out that the default installation of Jenkins runs it on user 'daemon'. This user does not have it's own home directory. Instead is uses root's home. Which is baaad, m'kay.

So, first step wast to reinstall Jenkins so that it would NOT run it with daemon user. Key to it is to select "Customize" during the installation process and select the option to create jenkins user. This seems to fix the problem, the jenkins is now running with it's own account. Awsum.

But still no luck.

Even though I created the ssh keys, the Jenkins does not seem to find them, and git keeps giving "status code 128: Host key verification failed." error. Hmm.

What I was missing was that the keys had to be added to heroku. For some reason I thought that "heroku login" owuld add them there, but obviously not (why would it). To make it work I did this as jenkins user:

heroku keys:add

But still nothing, same error. Wtf.

It turned out that actually the error was not about the ssh keys at all, but the missing server RSA fingerprint from known hosts. So, after I tried to clone the repository from shell (as jenkings user) the error went away!

...and was replaced with another one:

"fatal: empty ident not allowed"

It seems that Heroku requires that you set email and username for git (although it did not require that from commandline..)

But still nothing!

It seems that the jenkings for some unknown reason does not use the correct home path (/Users/Shared/Jenkins/Home), instead is leaves the /Home out. Then I created a symlink to .gitconfig on /Users/Shared/Jenkings...

sudo -s -u jenkins
cd /Users/Shared/Jenkings
ln -s Home/.gitconfig

And it worked! Yatzy!

Wednesday, January 11, 2012

Django static files on Heroku

After completing Django-Heroku Hello World, I realized that the static files were not served properly. I found this and after modifying urls.py like this it started working. Great!

Monday, August 23, 2010

RHEL is hell


Thursday, August 12, 2010

Splitting strings in shell script

Nice way to pass parameters to a script is to put them in a properties file and then read the file in the script and do something with each parameter in the file. But often it is neccessary to pass more than one parameter for each line. One way to do this is to use some kind of separator between the parameters and split each line in the script using the separator. Here is one way to do it.

Example input file:


To read this file, we can use script like this:

for LINE in `cat input_file.txt`
echo "First: ${arr[0]}"
echo "Second: ${arr[1]}

The output should be:

First: foo
Second: 2
First: bar
Second: 109
First: baz
Second: 23

Thursday, August 13, 2009

Amazon sells virtual servers

You can actually buy (or rent) virtual servers from Amazon!