jenkinsci/github-pr-coverage-status-plugin

Step ‘Publish coverage to GitHub’ aborted due to exception

KostasOneFile opened this issue · 10 comments

I am using GitHub Pull Request Builder Plugin to trigger a build on PR and I currently managed to post the test results and I am trying to post code coverage as well.

I am producing a coverage.xml report, which is around 66% - Lines, and I have added Record Master Coverage and Publish coverage to GitHub post-build actions but I end up getting this error below. Is it trying to access that coverage report in github?

I have read the documentation but perhaps I am missing something. Could anyone help me with this?

C:\Program Files (x86)\Jenkins\jobs\File Management - PR\workspace>exit 0
[Cobertura] Publishing Cobertura coverage report...
Publishing Cobertura coverage results...
Cobertura coverage report found.
Recording NUnit tests results
Master coverage 0%
[GitHub PR Status] start
[GitHub PR Status] getting master coverage...
use default coverage repo
ERROR: Step ‘Publish coverage to GitHub’ aborted due to exception:
java.io.FileNotFoundException: https://api.github.com/repos/OneFileLtd/file-management
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at org.kohsuke.github.Requester.parse(Requester.java:602)
Caused: java.io.FileNotFoundException: https://api.github.com/repos/OneFileLtd/file-management
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at org.kohsuke.github.Requester.parse(Requester.java:612)
at org.kohsuke.github.Requester.parse(Requester.java:594)
at org.kohsuke.github.Requester._to(Requester.java:272)
Caused: org.kohsuke.github.GHFileNotFoundException: {"message":"Not Found","documentation_url":"https://developer.github.com/v3/repos/#get"}
at org.kohsuke.github.Requester.handleApiError(Requester.java:686)
at org.kohsuke.github.Requester._to(Requester.java:293)
at org.kohsuke.github.Requester.to(Requester.java:234)
at org.kohsuke.github.GitHub.getRepository(GitHub.java:443)
at com.github.terma.jenkins.githubprcoveragestatus.GitHubPullRequestRepository.getGitHubRepository(GitHubPullRequestRepository.java:57)
Caused: java.io.IOException: Could not retrieve GitHub repository named OneFileLtd/file-management (Do you have properly set 'GitHub project' field in job configuration?)
at com.github.terma.jenkins.githubprcoveragestatus.GitHubPullRequestRepository.getGitHubRepository(GitHubPullRequestRepository.java:59)
at com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction.perform(CompareCoverageAction.java:98)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
at hudson.model.Build$BuildExecution.post2(Build.java:186)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
at hudson.model.Run.execute(Run.java:1749)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)

I renamed my coverage report xml to cobertura.xml so the Master coverage is not 0% any more. I still can't get the final step to work though.

If your GitHub repository is private, does your API token include full control of private repositories?

@KostasOneFile @f-lopes : Same issue I am facing... Is there any workaround did you find ? Yes I have configured API token too, still same issue. Thank you.

terma commented

@mohan08p do you use github.com or own instance?

@terma : Hi, I am using Github API url https://api.github.com along with a personal access token.

@terma : Here is a log for build failed,

[GitHub PR Status] start
ERROR: Build step failed with exception
java.lang.UnsupportedOperationException: Can't find ghprbPullId or scmVars in build variables!
at com.github.terma.jenkins.githubprcoveragestatus.PrIdAndUrlUtils.getPrId(PrIdAndUrlUtils.java:73)
at com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction.perform(CompareCoverageAction.java:105)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
at hudson.model.Run.execute(Run.java:1754)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Build step 'Publish coverage to GitHub' marked build as failure
Email was triggered for: Always
Sending email for trigger: Always

Hi @mohan08p

The GitHub PR Coverage status plugin will get the PR ID either from the GitHub PR Builder plugin or from the MultiBranch plugin.

If you're not using the PR Builder plugin, the plugin will try to get the PR ID from GitHub API (opened PRs) using the GIT_COMMIT, GIT_BRANCH and GIT_URL environment variables.

Did you try to print the available environment variables? Do the ghprbPullId or CHANGE_ID environment variables exist?

@f-lopes , i am facing same issue, i have also injected this 2 variables,,
image

am getting this error while testing code with jacoco, can any one help

[JaCoCo plugin] - /var/lib/jenkins/workspace/jacoco_test/src/main/java 1 files
[JaCoCo plugin] Loading inclusions files..
[JaCoCo plugin] inclusions: [**/*.class]
[JaCoCo plugin] exclusions: []
ERROR: Step ‘Record JaCoCo coverage report’ aborted due to exception:
java.io.IOException: Invalid execution data file.
at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.java:89)
at hudson.plugins.jacoco.ExecutionFileLoader.loadExecutionData(ExecutionFileLoader.java:95)
Caused: java.io.IOException: While reading execution data-file: /var/lib/jenkins/jobs/jacoco_test/builds/2/jacoco/execFiles/exec0/jacoco.exec
at hudson.plugins.jacoco.ExecutionFileLoader.loadExecutionData(ExecutionFileLoader.java:98)
at hudson.plugins.jacoco.ExecutionFileLoader.loadBundleCoverage(ExecutionFileLoader.java:139)
at hudson.plugins.jacoco.JacocoReportDir.parse(JacocoReportDir.java:110)
at hudson.plugins.jacoco.JacocoBuildAction.loadRatios(JacocoBuildAction.java:339)
at hudson.plugins.jacoco.JacocoBuildAction.load(JacocoBuildAction.java:326)
at hudson.plugins.jacoco.JacocoPublisher.perform(JacocoPublisher.java:657)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:79)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1073)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
at hudson.model.Run.execute(Run.java:1843)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Notifying upstream projects of job completion
Finished: FAILURE

@KostasOneFile Can you please tell me how did you use this plugin in Jenkinsfile?