I am using Jenkins Ver:2.176.3 for declarative multibranch pipeline. I have junit test in my application code base and using maven surefire plugin to run unit test using maven command.

Multibranch job page shows 'Test Result' link and 'Test Result Trend' graph also. I think this is being displayed/published here due to plugin 'test-results-analyzer'.

In declarative pipeline we have two stages as shown in code sample and we use maven commands. Now my problem is that this test result count same unit test for each stage of pipeline so the count of unit tests are being double on this Test Result of Jenkins job page.

I tried skipping unit test in stage 'package-IT' using maven option -DskipTests and as per log it does skip unit testing but still see the duplicate test results.

if know please suggest

stages{ 
                        stage('compile-N-test') {
                            agent {label 'agent'}
                            steps {
                                script {
                                    // mvn clean test
                                }
                            }
                        }

                        stage('packaging-IT') {
                            agent {label 'agent'}                           
                            steps {
                                script {
                                    //mvn verify                                
                                }
                            }
                        }   
1

There are 1 best solutions below

1
On

Finally i got the solution: in pipeline we are using withMaven() which invoke test result and keep adding it so increasing count.