Creating a Software Development Support Server

Software development requires a number of server based tools to support it. This post provides a quick list of such tools and then describes how to set them up.

  • Source Code Control
    • git, svn, mercurial
  • Continuous Integration
    • Jenkins/Huson
  • Static Analysis
    • Sonar

Git

Installation

This is probably already installed as it may come with the linux distribution (e.g. Ubuntu), else

  • sudo apt-get install git

Configuration

Apache

This is optional, but enables easier access to other services by providing proxies from port 80.

Installation

  • sudo apt-get install apache2
  • sudo a2enmod proxy
  • sudo a2enmod proxy_http

Configuration

none

Postgres

This is used later to support sonar.

Installation

  • sudo apt-get install postgresql postgresql-contrib
  • sudo apt-get install pgadmin3 (you will probably use the gui admin tool at some point)
    • At the time of writing, apt-get installs v9.4 of postgresql and 1.18 of pgadmin3,
    • Although this partially works, pgadmin3 core-dumped several times at me
    • This link has instructions for installing pgadmin3 v1.20
  • sudo -u postgres psql postgres (to configure the postgres admin user)
    • password postgres (from the psql propmt: to set the postgres user password)
    • CREATE EXTENSION adminpack; (to enable pgadmin to work with psql)
    • q (to quit psql)
  • Edit the file ‘/etc/postgresql/9.4/main/pg_hba.conf ‘
    • Change the line
      # Database administrative login by Unix domain socket
      local      all         postgres            peer
      to
      # Database administrative login by Unix domain socket
      local      all         postgres            md5

Other help:

Jenkins

Installation

  • wget -q -O – https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add –
  • sudo sh -c ‘echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list’
  • sudo apt-get update
  • sudo apt-get install jenkins

Configuration

  • edit /etc/defaults/jenkins
  • change ‘HTTP_PORT=8080’ to define the port you wish to use for jenkins, e.g. 8180

In order to get a proxy to jenkins from port 80, e.g. http://localhost/jenkins, we must configure the default apache Virtual host.

Add the following to the end of the <VirtualHost> element in the 000-default.config file typically found in ‘/etc/apache2/sites-available’.

ProxyRequests Off
AllowEncodedSlashes NoDecode
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /jenkins http://localhost:8180/jenkins
ProxyPassReverse /jenkins http://localhost:8180/jenkins

Then restart apache

  • sudo service apache2 restart (or sudo /etc/init.d/apache2 restart)

Sonar

Installation

  • add ‘deb http://downloads.sourceforge.net/project/sonar-pkg/deb binary/’ to the end of the file ‘/etc/apt/sources.list’ (http://sonar-pkg.sourceforge.net/)
  • sudo apt-get update
  • sudo apt-get install sonar
  • edit file /etc/opt/sonar/conf/sonar.properties
    • find the following section and uncomment/modify the appropriate lines
      # User credentials.
      # Permissions to create tables, indices and triggers must be granted to JDBC user.
      # The schema must be created first.
      sonar.jdbc.username=sonar
      sonar.jdbc.password=sonar
    • find the following section and uncomment/modify the appropriate line as follows
      #----- PostgreSQL 8.x/9.x
      # If you don't use the schema named "public", please refer to http://jira.codehaus.org/browse/SONAR-5000
      sonar.jdbc.url=jdbc:postgresql://localhost/sonar
    • Modify the sonar port using the following lines
      # TCP port for incoming HTTP connections. Disabled when value is -1.
      sonar.web.port=8280
    • Modify the url path/contex
      # Web context. When set, it must start with forward slash (for example /sonarqube).
      # The default value is root context (empty value).
      sonar.web.context=/sonar
  • Create user ‘sonar’ in posgres
    • start pgadmin3
    • add a new Login Role with name and password as written above in the sonar.properties file
    • add a new database named ‘sonar’ (or named as written in the sonar.properties file)

Other help:

Configuration

  • edit /etc/defaults/sonar
  • change ‘HTTP_PORT=8080’ to define the port you wish to use for jenkins, e.g. 8280

In order to get a proxy to sonar from port 80, e.g. http://localhost/sonar, we must configure the default apache Virtual host.

Add the following to the end of the <VirtualHost> element in the 000-default.config file typically found in ‘/etc/apache2/sites-available’.

ProxyRequests Off
AllowEncodedSlashes NoDecode
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /sonar http://localhost:8280/sonar
ProxyPassReverse /sonar http://localhost:8280/sonar

(Only the last two lines are required if you have the others already in the file)

Then restart apache

  • sudo service apache2 restart (or sudo /etc/init.d/apache2 restart)

Ports

Always a good idea to keep a record of what service is running on which port.

80 : apache
8080 : app server (wildfly, tomcat, etc)
5432: postgresql
8180: jenkins
8280: sonar