Friday, 28 November 2014

Cobertura configuration with jenkins

 Follow below Steps to Integrate cobertura with Jenkins

  Step 1) - Install cobertura plugin in Jenkins

  You can install plugin through Manage Jenkins

   Click on Manage Jenkins --> Manage Plugins --> Available --> Search for cobertura
   plugin --> Click on check box--> On bottom of page you find two buttons to install the
   plugin choose which suites you.

   Skip first point if cobertura plugin already installed on your Jenkins.

   Step 2) - Enable Cobertura in projects

   A)- Choose desired Project on which you want to configure cobertura.
               Click on Configure :: refer image


   B)- Go to Build Section ::
     Add command in Goals and options
     cobertura:cobertura –Dcobertura.report.format=xml 
     cobertura:cobertura -  This command initiate coverage functionality.
     – Dcobertura.report.format=xml - From this we are specifying that we need
      coverage report in  xml format.Refer below image.







    C)- After that Go to Post-build Actions ::
            Select Option Publish cobertura coverage report
        If you have multi module project then surely you have several coverage.xml file in
        different folders, So to cover all we need to provide a general path, you can see in
        above SnagIt, I used   
        **/target/site/cobertura/coverage.xml,
        so it can cover all coverage file under different target folders.

  Step 3)- Creating Views for Cobertura ::

       Go to Jenkins dashboard a Click on + option as mention in below screen

       It open a window where you can enter view name and check view option

      After providing required information, Click on Ok button -  It open a configuration
      widgets,you can configure it as required,  Required to choose below two options
      You can select your preferred job from Job Filters section

       And also need to provide portlets position ,Please refer


Enjoy!!

Monday, 1 September 2014

Jenkins Issues

In this post I am adding those several issues which I faced using Jenkins,
I will add more whenever I found


1)-  [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project project-name: Execution default-cli of goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar failed: A required class was missing while executing org.codehaus.mojo:sonar-maven-plugin:2.0:sonar: org/sonatype/aether/graph/DependencyFilter

If you see this error on Jenkins console it means there is compatibility issue of maven version  installed at your system and sonar-maven-plugin version  used in your project POM, In my case I have maven 3.1 at Jenkins server and 2.0 version of sonar-maven-plugin in POM , 

So to resolve this issues you need to upgrade your sonar-maven-plugin version as I upgrade it from 2.0 to 2.1 



                                <plugin>
                                    <groupId>org.codehaus.mojo</groupId>
                                     <artifactId>sonar-maven-plugin</artifactId>
                                     <version>2.1</version>
                                  </plugin>

2)- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (1) on project project-name: An Ant BuildException has occured: exec returned: 1

                                                       OR

[exec] bower backbone.paginator#0.8.1  ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/test.git", exit code

To solve this issue you need to follow two steps

1) - Check permission on  git://github.com/test.git , try to open the git url(which shows in error console (red color )) in browser with the same user name and password which you are using in Jenkins.

2)- Some time due to some permission issue Jenkins not able to hit directly to git url using git,
So we need to update git config.
you can simply fire a command  which tells to use https instead of git

git config --global url."https://".insteadOf git://

3)- I have also mention one jenkins issue in my other post , you can refer
http://pathakamit783.blogspot.in/2014/08/jenkins-you-must-use-post-method-to.html




4) -  Test coverage is showing zero %


Some time we are in dilemma that  why our test coverage is showing zero % when we have some successful test,
Like you can see the above snagit , I have 8 success test but my test coverage is still zero,
I thought it is an issue  but after wasting plenty of time , I got one conclusion as I have less number of line coverage as compared to my lines of code , So the total percentage is too low to displayed by sonar
To check this follow below steps
     a)- Click on  0.0% line coverage.
     b)- Select your test case.
     c)- In your particular test you can see line coverage percentage.
     d)- To see covered line select Line to cover from drop down.

5)- " Can not execute SonarQube analysis: Can not execute Findbugs with a timeout threshold value of 1200000 milliseconds: TimeoutException -> [Help 1]"

If you are facing such issue means your project is too large and it need more time to create findbugs-result.xml ,So to fix this issue you need to increase  sonar.findbugs.timeout uptu appropriate miliseconds.
you can find this property file here. Logon to sonar dashboard.
Settings > General Settings > Java > Findbugs > sonar.findbugs.timeout

Please refer below snagit.



6)- Can not execute SonarQube analysis: Can not execute Findbugs:            
      java.lang.OutOfMemoryError: GC overhead limit exceeded -
To fix this issue you need to increase memory size and also add GCoverheadlimit option under MAVEN_OPTS of jenkins job.Please refer below snip.