Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please improve the documentation on usage of this plugin #118

Open
sheetalj2205 opened this issue Mar 21, 2023 · 1 comment
Open

Please improve the documentation on usage of this plugin #118

sheetalj2205 opened this issue Mar 21, 2023 · 1 comment

Comments

@sheetalj2205
Copy link

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

@rsov
Copy link

rsov commented Mar 21, 2023

You will need 3 things:

  1. Test runner that can output coverage/cobertura-coverage.xml file

  2. 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]])
    }
  }
}
  1. Branch protection on main branch for CI check
    Screenshot 2023-03-22 at 09 17 21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants