Open sheetalj2205 opened 1 year ago
You will need 3 things:
Test runner that can output coverage/cobertura-coverage.xml
file
This in your jenkinsifle
stage('Record Coverage') {
when { branch 'main' }
steps {
script {
currentBuild.result = 'SUCCESS'
}
step([$class: 'MasterCoverageAction', scmVars: [GIT_URL: env.GIT_URL]])
}
}
stage('PR Coverage to Github') {
when { allOf { not { branch 'main' }; expression { return env.CHANGE_ID != null } } }
steps {
script { currentBuild.result = 'SUCCESS' }
// Don't fail whole pipeline if this step fails
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
step([$class: 'CompareCoverageAction', publishResultAs: 'statusCheck', scmVars: [GIT_URL: env.GIT_URL]])
}
}
}
Branch protection on main
branch for CI check
Describe your use-case which is not covered by existing documentation.
I want to integrate code coverage reports of Jacoco into my GitHub PRs. I want to know do I need all the files of this repo also in my project for the integration or if I can simply use the code given in usage in Jenkinsfile in the example. Please check this question for complete desciption: Link
Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.
No response