Hudson, Sonar, Maven, Nexus installation wizard
Required Software: In order to make all software work smoothly together, we need download the correct version to avoid confliction.
A lot of software needs to setup a environment variable to do some configuration to change the action at runtime. Here are the steps to do this. 1. Press “Winkey + Pause”, and then click the “Advanced system settings” link at left side. 2. Click the “Environment variables” button to the bottom of the “System Properties” Dialog. 3. Click “New” button to create a variable. 4. Input name and value for the fields on the popup dialog. Click OK to apply changes.
JDK 1. Click the jdk-6u30-windows-i586.exe, and follow the wizard to setup jdk. 2. Press “Winkey + Pause”, and then click the “Advanced system settings” link at left side. 3. Click the “Environment variables” button to the bottom of the “System Properties” Dialog. 4. Click “New” button to create “JAVA_HOME”, add value “C:\Program Files (x86)\Java\jdk1.6.0_30” for it. 5. Find the variable “path”, and add “%JAVA_HOME%\bin;” before it. 6. Press OK to apply the changes.
Sonar Plug-in for Huson
Copy the sonar.hpi into %HUDSON_HOME%\plugins. And restart the Tomcat server. Then the sonar plug-in will take effective in Hudson.
Sonar 1. Create database Save the following script as create_database.sql, and execute it on mysql command line tool.
2. unzip the distribution to C:\ 3. If you do not use the default embedded database, edit conf/sonar.properties to configure the database access. Templates are available for every supported database. Just uncomment the lines you want.
4. You can run sonar in standalone model by click C:/sonar-2.12/bin/windows-x86-32/ StartSonar.bat, and it will take port 80, you can use it by this link http://localhost:80/sonar. But we strongly recommend that you deploy it in web container. Let’s see the next step. 5. Add environment variable CATALINA_OPTS with value -Xmx1024m -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -XX:MaxPermSize=256m 6. Click C:\sonar-2.12\war\build-war.bat to create a war file. And then copy the sonar.war to C:\apache-tomcat-7.0.23\webapps Note: do NOT remove C:\sonar-2.12 after you deployed war file. The original folder is still useful. Prior to Sonar 2.2, the WAR file must be rebuilt each time the configuration is updated (new plugins or new extensions). From Sonar 2.2 onwards, the WAR file is now linked to the Sonar directory (the directory where the distribution is unzipped). It implies that : •the directory where the distribution is unzipped cannot be removed
•there is no need to rebuild the WAR when installing/uninstalling plugins or rule extensions
•the WAR file must be deployed on the host which contains the Sonar directory
•the WAR file must be rebuilt when the Sonar directory is moved
•the WAR file must be rebuilt when a configuration file is updated (directory conf/) 7. Restart the tomcat server. Access sonar by http://localhost:8080/sonar .
Configuration
JDK: configure the java_home of java runtime.
Maven: specify the maven home path.
3. If you have installed sonar.hpi, you can see the following segment in the “Configure system” page. set the following fields: Server URL : http://localhost:8080/sonar/ Database URL: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8 Database Driver: com.mysql.jdbc.Driver Database login: sonar Database password: sonar 4. At the same page, you can also set value for the “SMTP server”, so that Hudson will send mails to notify you when the build is broken or someone submitted error code to the SVN server. 5. and click “New Job” at left side. Give a name of the project and choice Build a Maven 2/3 project (Legacy), click “OK” button to navigate to next page. 6. At the “Source Code Management” choose the “SVN” option, specify value for “Repository URL”, and you will be asked for username and password later. You’d better specify the full path directly point at the project source folder, so that Hudson can find the pom.xml easily without any further configurations. e.g. svn://svnserver/SEC/projects/Megafon SNAP PoC/source code/trunk/brtconnector 7. If your workspace has the top-level pom.xml in somewhere other than the module root directory, specify the path (relative to the module root) here, such as parent/pom.xml. If left empty, defaults to pom.xml 8. If you have installed sona.phi plug-in, select the checkbox before “Sonar” at the bottom of the page at “Post build Action” section. 9. Click the “Save” button to save all changes.
Maven
Now open the "MAVEN_HOME\conf\setting.xml" and make some changes to make the Nexus take effective in maven.
And make the following changes to make sonar take effective in maven.
A lot of software needs to setup a environment variable to do some configuration to change the action at runtime. Here are the steps to do this. 1. Press “Winkey + Pause”, and then click the “Advanced system settings” link at left side. 2. Click the “Environment variables” button to the bottom of the “System Properties” Dialog. 3. Click “New” button to create a variable. 4. Input name and value for the fields on the popup dialog. Click OK to apply changes.
JDK 1. Click the jdk-6u30-windows-i586.exe, and follow the wizard to setup jdk. 2. Press “Winkey + Pause”, and then click the “Advanced system settings” link at left side. 3. Click the “Environment variables” button to the bottom of the “System Properties” Dialog. 4. Click “New” button to create “JAVA_HOME”, add value “C:\Program Files (x86)\Java\jdk1.6.0_30” for it. 5. Find the variable “path”, and add “%JAVA_HOME%\bin;” before it. 6. Press OK to apply the changes.
Sonar Plug-in for Huson
Copy the sonar.hpi into %HUDSON_HOME%\plugins. And restart the Tomcat server. Then the sonar plug-in will take effective in Hudson.
Sonar 1. Create database Save the following script as create_database.sql, and execute it on mysql command line tool.
- #
- # Create Sonar database and user.
- #
- # Command: mysql -u root -p < create_database.sql
- #
- CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
- CREATE USER 'sonar' IDENTIFIED BY 'sonar';
- GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
- GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
- FLUSH PRIVILEGES;
- sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
- sonar.jdbc.driverClassName: com.mysql.jdbc.Driver
- sonar.jdbc.validationQuery: select 1
- sonar.jdbc.username: sonar
- sonar.jdbc.password: sonar
•there is no need to rebuild the WAR when installing/uninstalling plugins or rule extensions
•the WAR file must be deployed on the host which contains the Sonar directory
•the WAR file must be rebuilt when the Sonar directory is moved
•the WAR file must be rebuilt when a configuration file is updated (directory conf/) 7. Restart the tomcat server. Access sonar by http://localhost:8080/sonar .
Configuration
JDK: configure the java_home of java runtime.
Maven: specify the maven home path.
3. If you have installed sonar.hpi, you can see the following segment in the “Configure system” page. set the following fields: Server URL : http://localhost:8080/sonar/ Database URL: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8 Database Driver: com.mysql.jdbc.Driver Database login: sonar Database password: sonar 4. At the same page, you can also set value for the “SMTP server”, so that Hudson will send mails to notify you when the build is broken or someone submitted error code to the SVN server. 5. and click “New Job” at left side. Give a name of the project and choice Build a Maven 2/3 project (Legacy), click “OK” button to navigate to next page. 6. At the “Source Code Management” choose the “SVN” option, specify value for “Repository URL”, and you will be asked for username and password later. You’d better specify the full path directly point at the project source folder, so that Hudson can find the pom.xml easily without any further configurations. e.g. svn://svnserver/SEC/projects/Megafon SNAP PoC/source code/trunk/brtconnector 7. If your workspace has the top-level pom.xml in somewhere other than the module root directory, specify the path (relative to the module root) here, such as parent/pom.xml. If left empty, defaults to pom.xml 8. If you have installed sona.phi plug-in, select the checkbox before “Sonar” at the bottom of the page at “Post build Action” section. 9. Click the “Save” button to save all changes.
Maven
Now open the "MAVEN_HOME\conf\setting.xml" and make some changes to make the Nexus take effective in maven.
- <mirror>
- <id>nexus</id>
- <mirrorOf>*</mirrorOf>
- <url>http://localhost:8080/nexus/</url>
- </mirror>
And make the following changes to make sonar take effective in maven.
- <profile>
- <id>sonar</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <properties>
- <!-- EXAMPLE FOR MYSQL -->
- <sonar.jdbc.url>
- jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
- </sonar.jdbc.url>
- <sonar.jdbc.driverClassName>com.mysql.jdbc.Driver</sonar.jdbc.driverClassName>
- <sonar.jdbc.username>sonar</sonar.jdbc.username>
- <sonar.jdbc.password>sonar</sonar.jdbc.password>
- <!-- optional URL to server. Default value is http://localhost:9000 -->
- <sonar.host.url>
- http://localhost:8080/sonar
- </sonar.host.url>
- </properties>
- </profile>
- <activeProfiles>
- <activeProfile>sonar</activeProfile>
- </activeProfiles>