Friday, February 22, 2013

Install Jenkins Build System on Ubuntu 11

Install/setup Subversion
  1. sudo apt-get update
  2. sudo apt-get install subversion
  3. cd /var
  4. sudo mkdir svn
  5. sudo svnadmin create /var/svn/repos
  6. sudo adduser svn
  7. sudo chown -R svn.svn svn
  8. sudo vigr

Install Openssh:
  1. sudo apt-get install openssh-server
  2. svn co svn+ssh://pwong@localhost/var/svn/repos to make sure ssh is working
  3. chmod 0700 ~/.ssh
  4. chmod 0600 ~/.ssh/known_hosts
Install/setup Apache and DAV:
  1. sudo apt-get install libapache2-svn apache2
  2. sudo vi /etc/apache2/mods-enabled/dav_svn.conf to remove comments for following lines:
    DAV svn
    SVNPath /var/svn/repos
    AuthType Basic
    AuthName "Subversion Repository"
    AuthUserFile /etc/apache2/dav_svn.authz
    Require valid-user
  3. sudo htpasswd -cb /etc/apache2/dav_svn.authz pwong password
  4. sudo /etc/init.d/apache2 force-reload, then check http://localhost/svn/
Install/setup Trac:
  1. sudo apt-get install trac python-setuptools libapache2-mod-python enscript
  2. sudo mkdir /var/www/trac
  3. sudo trac-admin /var/www/trac/repos initenv, accept defaults, and enter /var/svn/repos for repository.
  4. cd /var/www
  5. sudo chown -R www-data.svn trac
  6. cd /etc/apache2/mods-enabled/
  7. sudo vi python.conf to create w new config file

  8. AuthType Basic
    AuthName "Subversion Repository"
    AuthUserFile /etc/apache2/dav_svn.authz
    Require valid-user
    SetHandler mod_python
    PythonInterpreter main_interpreter
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnvParentDir /var/www/trac
    PythonOption TracUriRoot /trac
  9. sudo /etc/init.d/apache2 force-reload, then check http://localhost/trac/
Install Java and Tomcat:
  1. sudo apt-get install sun-java6-jdk
  2. sudo apt-get install tomcat6 tomcat6-admin
  3. sudo vi /usr/share/tomcat6/bin/ to add "export JAVA_HOME=/usr/lib/jvm/java-6-sun"
  4. sudo vi /usr/share/tomcat6/bin/ to add the some line to the file
  5. sudo vi /etc/init.d/tomcat6 to add the same line to the file
  6. sudo vi /etc/tomcat6/tomcat-users.xml to add "

  7. sudo /etc/init.d/tomcat6 restart, then check http://localhost:8080
Install/setup Jenkins:
  1. sudo wget -q -o - | sudo apt-key add -
  2. sudo vi /etc/apt/sources.list to append "ded binary/" to the file
  3. sudo apt-get update
  4. sudo apt-get install jenkinz
  5. sudo vi /etc/default/jenkinz to change the http port from 8080 to 8180. Otherwise, Jenkins won't be started at the default port 8080. Check http://locahost:8180 for Jenkins
  6. sudo /etc/init.d/jenkins start
Install Maven and Ant:
  1. sudo apt-get install maven2 ant
  2. cd ~/MyProject
  3. mvn archetype:create -DartifactId=superapp
  4. cd superapp
  5. mvn package
  6. java -cp target/superapp-1.0-SNAPSHOT.jar
  7. mvn clean
  8. mkdir superapp-structure
  9. mv superapp-structure/ ..
  10. cd ..
  11. mv superapp superapp-structure/trunk
  12. mkdir superapp-structure/branches
  13. mkdir superapp-structure/tags
  14. sudo svn import superapp-structure file:///var/svn/repos/superapp-repository/superapp -m "First import.". The superapp-repository will be visible at http://localhost/trac/repos/browser
Checkout the working copy of project:
  1. svn co file:///var/svn/repos/superapp-repository/superapp/trunk superapp

SSH Login Without Password

A. Empty passphrase in keys:

1: On local host, create public and private keys using ssh-key-gen by pressing enter 3 times to either use default or without passphrase.


2: Copy public key to remote host with ssh-copy-id

    ssh-copy-id -i ~/.ssh/ remote-host

Make sure .ssh/authorized_keys exist on remote host. From now on, the remote host shouldn't ask your password for login.

B. If there is passphrase in keys for any reason, following additional steps are needed.

1. Start up ssh-agent or put following line in ~/.bashrc to memorize the passphrase.  
    eval $(ssh-agent -s)

2. Add key to the agent. It needs to enter  the passphrase to complete the step.

    ssh-add ~/.ssh/id_rsa

3. Conform the key has been added.

     ssh-add -l

No need to enter the passphrase to login to the remote host.