How to configure a continuous integration architecture at home? (1/3)

Initially published on July 17th, 2015 but updated on August 4th, 2015.

I am using the Synology214play to host the server side of my homelabs. It is a NAS running over an Intel Atom Evansport CE5335 i686 processor. This server will host all necessary components including MariaDB as database, Tomcat as Servlet Container, Jenkins as Continuous Integration Server, Git as Source Control System and SonarQube as Quality Management Platform.

Here below, you will find some of my notes concerning the basic setup of those components.

Ref. to the complete series:


Setting-up Java SE 8u51 on DSM5.2

From the DiskStation Manager:

  1. Create a shared directory on Synology that you call “public” (caution: this is case sensitive),
  2. Approve the Oracle licence agreement, download x86 Linux Small Footprint – Headless and load the archive into the “public” repository that you have just created,
  3. Add a reference to http://packages.pcloadletter.co.uk as to the source list of the Package Manager,
  4. If there was a previous java version on your server, remove it with Java Manager,
  5. Finally, install Java SE 8u51 with the Package Manager.

What about the Java keystore?

Let’s assume you have appropriately set up SSH on the Synology Server. You are also probably already enjoying some of the nice features provided by Synology and its community like ldap or SSO. In such a case, you may want to use self-signed certificates to connect Jenkins. Thus, just try to import an existing certificate that you previously have placed into “/volume1/public” into the Java keystore. You will be asked for a password which is ‘changit’ by default.

/: echo $JAVA_HOME
/: cd [JAVA_HOME]/lib
/: keytool -import -trustcacerts -alias [MY_ALIAS] -file /volume1/public/ca.crt -keystore security/cacerts

Setting-up Apache Tomcat 7

Tomcat version 7 is compatible with Java SE 8. Once Java has been setup, Tomcat can be installed from the Package Manager. It will host our Jenkins server.
Please note that you must apply some configuration steps at this stage. Indeed, because of security issues which were unsafe for tomcat, the seventh version prevents by default anyone to manage applications as long as no REALM has been appropriately set.

  1. Open a SSH connexion with Root priviledges to the Synology server (e.g., using Putty),
  2. Modify tomcat-users.xml file:
    /: cd /[MY_INSTALLATION_VOLUME]/@appstore/Tomcat7/src/conf/
    /[MY_INSTALLATION_VOLUME]/@appstore/Tomcat7/src/conf: vi tomcat-users.xml
    
  3. Insert the following lines, save and quit ESC + :wq!:
    <role rolename="manager"/>
    <role rolename="manager-gui"/>;
    <role rolename="admin"/>;
    <user username="[MY_TOMCAT_USER]" password="[MY_TOMCAT_PASSWORD]" roles="admin,manager,manager-gui"/>;
    
  4. In order to host Jenkins, extend the size limit that Tomcat is able to host to 100MB by modifying the /[MY_INSTALLATION_VOLUME]/@appstore/tomcat7/webapps/manager/WEB-INF/web.xml file:
    <multipart-config>
    <!-– 50MB max –->
    <max-file-size>100000000</max-file-size>
    <max-request-size>100000000</max-request-size>
    <file-size-threshold>0</file-size-threshold>
    </multipart-config>
    
  5. Restart Tomcat. The default port is 7070.

Setting-up Maven 3.3.3

  1. Download Maven 3.3.3 (bin.tar.gz),
  2. Move the archive to the repository you want (e.g., /[MY_INSTALLATION_VOLUME]/@appstore/), extract it then update your path by editing “/etc/profile”,
    /: mv apache-maven-3.3.3/ /[MY_INSTALLATION_VOLUME]/@appstore/
    /: cd /[MY_INSTALLATION_VOLUME]/@appstore
    /[MY_INSTALLATION_VOLUME]/@appstore/: tar xzvf maven.tar.gz
    /[MY_INSTALLATION_VOLUME]/@appstore/: vi /etc/profile
    

    #/etc/profile
    PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
    # Insert this line
    PATH=/[MY_INSTALLATION_VOLUME]/@appstore/apache-maven-3.3.3/bin:$PATH
    export PATH

    /[MY_INSTALLATION_VOLUME]/@appstore/: cp /etc/profile [MY_USER_PROFILE]
    /[MY_INSTALLATION_VOLUME]/@appstore/: mvn -v
    

    Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T12:57:37+01:00)
    Maven home: /[MY_INSTALLATION_VOLUME]/@appstore/apache-maven-3.3.3
    Java version: 1.8.0_51, vendor: Oracle Corporation
    Java home: /[MY_INSTALLATION_VOLUME]/@appstore/java8/ejdk1.8.0_51/linux_i586/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: “linux”, version: “3.2.40”, arch: “i386”, family: “unix”


Setting-up Jenkins 1.620

  1. Download Jenkins,
  2. Deploy the war using Tomcat Web Application Manager,
  3. Set JENKINS_HOME on /[MY_INSTALLATION_VOLUME]/@appstore/Tomcat7/src/conf/context.xml,
    <Environment name="JENKINS_HOME" value="/[MY_INSTALLATION_VOLUME]/@appstore/jenkins" type="java.lang.String"/>
    
  4. Set UTF-8 as codepage in on /[MY_INSTALLATION_VOLUME]/@appstore/Tomcat7/src/conf/server.xml:
    <Connector port="7070" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
    
  5. Restart Tomcat,
  6. Access to the Jenkins Console : http://[SYNOLOGY]:7070/jenkins.

Setting-up SonarQube 5.1.1

  1. Database: Assuming MariaDB has been installed via Synology Package Manager, create an empty schema and a sonarqube user then grant this sonarqube user CRUD permissions on the schema.
    mysql -u[MARIA_DB_ADMIN] -p[MARIA_DB_ADMIN_PASSWORD]
    
    CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
    CREATE USER 'sonarqube'@'%' IDENTIFIED BY 'initial';
    GRANT ALL PRIVILEGES ON sonar.* TO 'sonarqube'@'%';
    flush privileges;
    
    CREATE USER 'sonarqube'@'localhost' IDENTIFIED BY 'initial';
    GRANT ALL PRIVILEGES ON sonar.* TO 'sonarqube'@'localhost';
    flush privileges;
    
  2. Web Server: Download SonarQube and import the archive in your favorite folder (e.g., /[MY_INSTALLATION_VOLUME]@appstore/),
    /: unzip sonarqube-5.1.1.zip
    /: cd sonarqube-5.1.1/conf/
    /: vi sonar.properties 
    

    sonar.jdbc.username=sonarqube
    sonar.jdbc.password=initial
    sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

  3. On synology, modify the startup script as described by Michael Engelhardt.
  4. Create a link on it then edit /etc/rc.local:
  5. /: ln -s /[MY_INSTALLATION_VOLUME]/@appstore/sonarqube-5.1.1/bin/linux-x86-32/sonar.sh /usr/bin/sonar
    /: vi /etc/rc.local
    /: chmod 755 /etc/rc.local
    

    #!/bin/sh
    exec /usr/bin/sonar
    exit 0

  6. Access to the sonarQube Console : http://[SYNOLOGY]:9000/ – default credentials are “admin” – “admin”.

Further readings?


About the author

Freelancer, IT Architect and Program Manager, Ludovic Fernandez is specialized in designing and realizing innovative and reliable enterprise applications.

Feel free to refer to this page on