Using the Reporting Pom - novoda/public-mvn-repo GitHub Wiki

Contents

  1. Required Pom Changes for Existing Projects
  2. Setup new Jenkins Job
  3. Changes to Pom if you are not extending Novoda.Reporting.pom

Unfortunately you cannot simply transfer an existing Jenkins Maven build to a free-style build. You have to create new build. See SQLite Provider for a worked example.

Required Pom Changes for Existing Projects

  • Change your parent to be the Novoda reporting pom
<parent>
<groupId>com.novoda</groupId>
<artifactId>reporting</artifactId>
<version>1.1.0</version>
</parent>
  • Add this property if your package doesn’t start ‘com.novoda’ (req: FindBugs)
<properties>
<reporting.package.analyze>com.client.package.*</reporting.package.analyze>
</properties>
  • Create the folder /team-props/ and add these properties files lint.xml, findbugs-exclude.xml, checkstyle.xml

Example can be found at Team Props Example

Setup new Jenkins job

See SQLite Provider for worked example

1. Create free-style project with project name

If your project has more than one build indicate difference such as PROJECT_NAME - BRANCH_NAME

2. Add Description especially for open source projects

3. Discard Old Builds

Max number of builds to 50 (it is nice to have history but space is precious)

4. Source Code Management (Git):

  • Provide project Repository URL example [email protected]:novoda/P2D2.git
  • Click on Advanced button and in Branch Specifier enter name of branch, usually master (you can leave this field empty and by default on each Jenkins will try to run whole setup, however be aware if you break something in your personal branch everybody will know about it including clients if they have access to build which will be confusing for them as most of them are non-technical)

5. Build Triggers

Select Build when a change is pushed to GitHub

6. Build

  • Choose Invoke top-level Maven Targets.
    • In Maven Version select MVN3 and in Goals type: clean install
  • Select Add build step, select Execute shell
mvn cobertura:cobertura;
mvn findbugs:findbugs;
mvn pmd:pmd;
mvn test;
mvn checkstyle:checkstyle;
lint --config team-props/lint.xml --xml lint-results.xml .;

7. Post-build Actions

  • Publish Android Lint results with Lint files **/lint-results.xml

  • Publish Checkstyle analysis results with Checkstyle results **/checkstyle-result.xml

  • Publish FindBugs analytics results with FindBugs results **/findbugsXml.xml

  • Publish PMD analysis results with PMD results **/pmd.xml

  • Publish Cobertura Coverage Reports with **/target/site/cobertura/coverage.xml

  • Add Sonar no extra settings required

  • Add the Continuous Integration game

  • Incase there are JUnit reports in app Publish JUnit test result report with app/target/surefire-reports/*.xml

  • E-mail Notification enter [email protected] and check

    • Send e-mail for every unstable build
    • Send separate e-mails to individuals who broke the build

Required changes for projects not using the reporting parent pom

See Reporting for worked example.

  1. Add Cobertura dependency
<build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.5.1</version>
        <configuration>
          <formats>
            <format>xml</format>
          </formats>
          <check/>
        </configuration>
        <executions>
          <execution>
            <phase>clean</phase>
            <goals>
              <goal>cobertura</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
</build>
  1. Add Cobertura
 <reporting>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.5.1</version>
      </plugin>
    </plugins>
  </reporting>
  1. Add Checkstyle
<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.9.1</version>
        <configuration>
          <configLocation>checkstyle.xml</configLocation>
        </configuration>
      </plugin>
    </plugins>
</build>
  1. Add FindBugs
<reporting>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>2.5.1</version>
        <configuration>
          <xmlOutput>true</xmlOutput>
          <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
        </configuration>
      </plugin>
     </plugins>
  </reporting>
  1. Add PMD
<reporting>
    <plugins>
<plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-pmd-plugin</artifactId>
           <version>2.7.1</version>
      </plugin>
    </plugins>
</reporting>

  1. Add Surefire
<build>
    <sourceDirectory>src</sourceDirectory>
    <testSourceDirectory>test</testSourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.12.4</version>
        <configuration>
          <includes>
            <include>**/*Test*.java</include>
            <include>**/*Should.java</include>
          </includes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  1. Set the properties
  <properties>
    <reporting.package.analyze>com.client.package.*</reporting.package.analyze>
    <reporting.findbugs.exclude>team-props/findbugs-exclude.xml</reporting.findbugs.exclude>
    <reporting.checkstyle.rules>team-props/checkstyle.xml</reporting.checkstyle.rules>
  </properties>
  1. Create the folder /team-props/ and add these properties files lint.xml, findbugs-exclude.xml, checkstyle.xml

Example can be found at Team Props Example

⚠️ **GitHub.com Fallback** ⚠️