Giter Site home page Giter Site logo

jenkinsci / github-pr-coverage-status-plugin Goto Github PK

View Code? Open in Web Editor NEW
93.0 12.0 101.0 330 KB

Nice test coverage icon for your pull requests just from Jenkins

Home Page: https://plugins.jenkins.io/github-pr-coverage-status/

License: Apache License 2.0

Java 94.96% HTML 3.93% Groovy 1.12%
jenkins-plugin pull-requests coverage badge adopt-this-plugin

github-pr-coverage-status-plugin's Introduction

GitHub Pull Request Coverage Status Plugin for Jenkins

Code coverage icon for GitHub pull requests

Build Status

Overview

Parse code coverage report generated by build and post code coverage status comment to GitHub pull request: Example

Supports coverage reports

  • Jacoco jacoco.xml
  • Cobertura cobertura.xml or cobertura-coverage.xml
  • Clover clover.xml
  • SimpleCov JSON (Ruby) coverage.json

How to use

Install Plugin

  • Install plugin from Jenkins Plugin Repository
  • Or manually
    • Goto releases
    • Download latest version of plugin .hpi file
    • Install to your Jenkins guide

Configure access to GitHub

  • Goto Manage Jenkins | Configure System
  • Find section Coverage status for GitHub Pull Requests
  • Configure global settings of plugin
    • GitHub API URL keep blank for GitHub.com and fill if for dedicated instance of GitHub, example: http(s)://hostname/api/v3/
    • Set Personal Access Token (or keep blank if anonymous access enabled)

Configure master coverage source

To be able compare Pull Request coverage plugin needs master coverage for GitHub repository.

Jenkins build

  • Add Record Master Coverage post build step to build which tests your master. Coverage will be stored per repository URL

Sonar

You have the option to get the master coverage (base coverage) from your SonarQube instance. Otherwise the plugin will keep track of the master coverage in the project configuration file.

  • Goto Manage Jenkins
  • Find section Coverage status for GitHub Pull Requests
  • Fill Sonar URL field - e.g. http://sonar.mycompany.com
  • Turn On Use Sonar for master coverage
  • Optionally use can specify your personal Sonar access token.
  • The next pull request build will use SonarQube as the the source for master coverage

The plugin will try to find the project in SonarQube based on the repository name. If more than one projects match, a warning is logged, and the first one will be used to get the coverage data.

Publish coverage for pull request

Depends on plugin which you are using to run (trigger) pull request in Jenkins.

GitHub Pull Request Builder Plugin

Branch API Plugin

  • To Jenkins Job triggered by Branch API Plugin add Publish coverage to GitHub post build step
  • Ensure that build create code coverage report file

Other

  • Before Publish coverage to GitHub step inject CHANGE_ID and CHANGE_URL to build envs where first one is Pull Request ID (number) and second link to repository
  • Add Publish coverage to GitHub post build step to build
  • Ensure that build create code coverage report file

How to use with Jenkins Pipelines

  • After running tests set build result to Success

    • currentBuild.result = 'SUCCESS'
  • Trigger MasterCoverageAction to collect master coverage (scmVars is needed for multibranch)

    • step([$class: 'MasterCoverageAction', scmVars: [GIT_URL: env.GIT_URL]])
    • Optionally you can specify jacoco counter type like this: step([$class: 'MasterCoverageAction', jacocoCounterType: 'INSTRUCTION', scmVars: [GIT_URL: env.GIT_URL]])
    • You can also specify how the result will pe published (comment or status check). By default it will be published as a status check step([$class: 'MasterCoverageAction', jacocoCounterType: 'INSTRUCTION', publishResultAs: 'statusCheck', scmVars: [GIT_URL: env.GIT_URL]])
  • Trigger CompareCoverageAction to compare coverage and publish results (scmVars is needed for multibranch)

    • step([$class: 'CompareCoverageAction', scmVars: [GIT_URL: env.GIT_URL]])
    • Optionally use can specify here jacoco counter type and sonar login and sonar password like this: step([$class: 'CompareCoverageAction', jacocoCounterType: 'INSTRUCTION', sonarLogin: "login", sonarPassword: "password"])
    • You can also specify how the result will pe published (comment or status check). By default it will be published as a status check step([$class: 'MasterCoverageAction', jacocoCounterType: 'INSTRUCTION', publishResultAs: 'statusCheck', scmVars: [GIT_URL: env.GIT_URL]])
  • Simple Multibranch Pipeline example

 pipeline {
    agent {
        label 'linux'
    }
    tools {
        maven 'maven-3.0.3'
    }
    stages {
        stage('Checkout') {
            steps {
                checkout scm
            }
        }
        stage('Build and Test') {
            steps {
                sh 'mvn clean package'
            }
        }
        stage('Record Coverage') {
            when { branch 'master' }
            steps {
                script {
                    currentBuild.result = 'SUCCESS'
                 }
                step([$class: 'MasterCoverageAction', scmVars: [GIT_URL: env.GIT_URL]])
            }
        }
        stage('PR Coverage to Github') {
            when { allOf {not { branch 'master' }; expression { return env.CHANGE_ID != null }} }
            steps {
                script {
                    currentBuild.result = 'SUCCESS'
                 }
                step([$class: 'CompareCoverageAction', publishResultAs: 'statusCheck', scmVars: [GIT_URL: env.GIT_URL]])
            }
        }
    }

Troubleshooting

No coverage picture and my Jenkins is in private network and not accessible for GitHub

Because of that GitHub can't render icon picture hosted on Jenkins. Plugin can use http://shields.io public resource instead of Jenkins hosted picture. To use it:

  • Goto Jenkins Configuration
  • Turn on Jenkins is not accessible for GitHub
  • Done next coverage comment in Pull Request will use http://shields.io

No coverage picture on GitHub Pull Request Page

If you see next picture on your pull request in GitHub:

No coverage picture

In most cases that mean that your Jenkins runs on http instead of https Plugin uses same protocol as your Jenkins, however GitHub in most cases accessible by https Default browser policy to block non secure resources on secure pages from unknown domain.

To fix that:

  1. Configure Jenkins to be accessible for https https://jenkins.io/doc/book/installing/#configuring-http
  2. Next you have a few options:
  • Run your Jenkins on https only
  • Or configure plugin to publish link on picture over https
    • Open Jenkins
    • Click Manage Jenkins
    • Click Configure System
      • Find section Coverage status for GitHub Pull Requests
      • Find property Jenkins URL for icon in Pull Request
      • Put URL to your Jenkins with https like https://jenkins.my.com
      • Save
    • Restart Jenkins

Plugin settings

Changelog

  • Remove non-UTF-8 symbol from version
  • Fail the status check when the coverage decreased
  • Non back compatible change minimum Java version 8 (before 7) & Jenkins 2.7 (before 1.5...)
  • Github-api lib upgraded to 1.90
  • Add params support for freestyle jobs
  • Allow publishing result as a status check
  • Allow counter type selection for Jacoco
  • Update jacoco from 0.7.5.x to 0.8.1
  • Use scmVars before env variables for git url detection
  • Allow to disable SimpleCov Coverage parser
  • Add support of Workflow SCM Step Plugin
  • Fix Master showing 0% even after RecordMasterCoverage is run
  • Sonar token & login/password authentication
  • SimpleCov JSON report fix coverage
  • Support single quotes for Cobertura Report
  • Cobertura plugin ignores zero for lineRate or branchRate as result lineRate=0 branchRate=0.5 => Coverage 25% became 0.5 as lineRate=0, same policy for branchRate
  • Log Enchacements

1.5.0

Supporting Master Coverage from SonarQube. Check (details)[#master-coverage-from-sonar]

1.4.0

Supporting of private Jenkins with public GitHub. To enable that mode goto Jenkins Configuration and turn on Jenkins is not accessible for GitHub

1.3.0

Add support SimpleCov JSON coverage report for Ruby

1.2.0

Add alternative text to coverage image for case when GitHub doesn't able to show image

1.1.1

Correct parsing Cobertura report for edge cases

1.0.8

First public release to Jenkins Plugin Repo

github-pr-coverage-status-plugin's People

Contributors

aakavalevich avatar adnancerner avatar basil avatar dependabot[bot] avatar dmotpan avatar dncarley avatar gimler avatar grigaci avatar keperry avatar lextiz avatar mblair avatar mduesterhoeft avatar michaelbjames avatar msabramo avatar richid avatar sharpek avatar soliad avatar stevegal avatar tacnoma avatar terma avatar yunir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

github-pr-coverage-status-plugin's Issues

Coverage is not collecting from my branch

I am getting 0.0 build coverage as well as for master coverage 0.0

[GitHub PR Status] start

[GitHub PR Status] getting master coverage...

use default coverage repo

[GitHub PR Status] master coverage: 0.0

[GitHub PR Status] collecting coverage...

[GitHub PR Status] build coverage: 0.0

[GitHub PR Status] Coverage 0% changed 0.0% vs master 0%

[GitHub PR Status] publishing result as status check

I getting this message. cannot collect coverage report using clover.xml file can someone help me?

"WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?"

We are using sonarscanner 2.8.1
In analysis properties:
sonar.analysis.mode=preview
sonar.sources=modules.
But in Console:
INFO: ANALYSIS SUCCESSFUL
INFO: Executing post-job GitHub Pull Request Issue Publisher
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:22.184s
INFO: Final Memory: 238M/11718M
INFO: ------------------------------------------------------------------------
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?

How to resolve this issue.

No jacocoTestReport in Git Repo

Hey,

For numerous reasons we don't store the jacocoTestReport.xml in our GitHub repos, however it is generated during our jenkins process in a docker container. Would it be possible to provide a git repo url and a jacocoTestReport when calling step([$class: 'CompareCoverageAction', scmVars: env.GIT_URL])?

Plugin not working in slave environment

The Plugin won't work in an environment where Branch Builder Plugin and Jenkins slaves are used since they won't have access to env variables of the master.

Master showing 0% even after RecordMasterCoverage is run

After the upgrade to 1.8.1, our master coverage began reporting as 0%. This seems to be caused by using different methods to store and retrieve the data in the master coverage map. I can't be sure if it is specific to GitHub Enterprise, but that is what we are using.

The issue appears to be here:
a66d77b#diff-22ca09200b10d3f4df393e13a098a24eR33

It is doing a lookup on repo-name, but our repo name is stored in the map as [email protected]/repo-name. When passing the FQRN ([email protected]/repo-name) the proper coverage value comes back.

Steps to reproduce:

  • Run a job that adds master coverage
  • Open the script console
  • confirm the entry is there:
import com.github.terma.jenkins.githubprcoveragestatus.*

com.github.terma.jenkins.githubprcoveragestatus.Configuration.ConfigurationDescriptor blah = new com.github.terma.jenkins.githubprcoveragestatus.Configuration.ConfigurationDescriptor()

println(blah.getCoverageByRepo())
  • Check org/repo-name:
import com.github.terma.jenkins.githubprcoveragestatus.*
  
com.github.terma.jenkins.githubprcoveragestatus.Configuration.ConfigurationDescriptor blah = new com.github.terma.jenkins.githubprcoveragestatus.Configuration.ConfigurationDescriptor()

println(blah.getCoverageByRepo().get("repo-name"))
  • comes back null
  • check by FQRN
import com.github.terma.jenkins.githubprcoveragestatus.*
  
com.github.terma.jenkins.githubprcoveragestatus.Configuration.ConfigurationDescriptor blah = new com.github.terma.jenkins.githubprcoveragestatus.Configuration.ConfigurationDescriptor()

println(blah.getCoverageByRepo().get("[email protected]:org/repo-name.git"))
  • comes back with valid float

Add option to search for Sonar project by the projectKey

I am using your plugin in a pipeline and it is having issues finding my master project in Sonar. The repo name is something along the lines of my-repo and the project name in Sonar is My Repo. When using step([$class: 'CompareCoverageAction']) it searches Sonar for http://sonarurl/api/projects/index?search=my-repo and does not find the project (oddly enough if I hit the api with my_repo with an underscore instead of a dash it will find it). It'd be nice if I could do something like step([$class: 'CompareCoverageAction' key: 'my-repo']) hit http://sonarurl/api/projects/index?key=my-repo to find the master project.

Old recorded master coverage

12:46:56 Master coverage +29%

Later when run on a pull request branch
14:53:59 [GitHub PR Status] master coverage: 0.27715
14:53:59 [GitHub PR Status] collecting coverage...
14:54:00 [GitHub PR Status] build coverage: 0.28635
14:54:00 [GitHub PR Status] Coverage 29% changed +0.92% vs master 28%

Where does it take master 28%? It should be 29%. I think it compares to some old master records.

Build coverage value in jenkins not matching with the coverage value in sonarqube

We did a gitHub+Jenkins+Sonar integration. After the execution of Jenkins job, Code Coverage in sonarqube is updated with 26.6%(jacoco-ut.exec). But in Build coverage, it is updated as 20.54%. From where the Jenkins getting the build coverage value if it is from jacoco.xml, why there is a discrepancy and how to resolve this?Please advise.

"Jenkins URL for icon in Pull Request" Option Not Functioning.

I tried to give some customized URL in option "Jenkins URL for icon in Pull Request" for making the respective URL as the hyperlink/reference of the Image/Icon, But irrespective of configuration, the Image/Icon referencing same Jenkins URL always.

Plugin Name: GitHub Pull Request Coverage Status
The Icon referencing URL currently: http://jenkins_url/repo_name/$build_number/
Required Icon referencing URL is: http://jenkins_url/repo_name/$build_number/custom/

By passing the value http://jenkins_url/repo_name/$build_number/custom/ in the option "Jenkins URL for icon in Pull Request" should work, but it's not actually working as expected.

It seems there is a bug in the plugin, please suggest how we can achieve our requirement here.

currentBuild.status = SUCCESS

Why we need to set currentBuild.status = 'SUCCESS'?

It is very strange since I have another stages after my test stage and once I set currentBuild.status = 'SUCCESS' I need to start to control this status manually.

WARNING: failed to uncoerce com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction@47dba41

Using step([$class: 'CompareCoverageAction', ...]) in a declarative pipeline results in the following warning in the Jenkins master logs:

Apr 11, 2019 3:09:09 PM org.jenkinsci.plugins.structs.describable.DescribableParameter uncoerce
WARNING: failed to uncoerce com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction@47dba41
java.lang.UnsupportedOperationException: no public field ‘sonarLogin’ (or getter method) found in class com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction
	at org.jenkinsci.plugins.structs.describable.DescribableParameter.getValue(DescribableParameter.java:161)
	at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:142)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2(DescribableModel.java:584)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2_(DescribableModel.java:675)
	at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:196)
	at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:142)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2(DescribableModel.java:584)
	at org.jenkinsci.plugins.workflow.actions.ArgumentsAction.resolve(ArgumentsAction.java:308)
	at org.jenkinsci.plugins.workflow.actions.ArgumentsAction.getResolvedArguments(ArgumentsAction.java:295)
	at org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode.getDelegateType(StepAtomNode.java:134)
	at org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode.effectiveDisplayName(StepAtomNode.java:90)
	at org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode.getTypeDisplayName(StepAtomNode.java:102)
	at org.jenkinsci.plugins.workflow.graph.FlowNode.getDisplayName(FlowNode.java:258)
	at com.cloudbees.workflow.rest.external.FlowNodeExt.addBasicNodeData(FlowNodeExt.java:194)
	at com.cloudbees.workflow.rest.external.AtomFlowNodeExt.create(AtomFlowNodeExt.java:70)
	at com.cloudbees.workflow.rest.external.ChunkVisitor.makeAtomNode(ChunkVisitor.java:68)
	at com.cloudbees.workflow.rest.external.ChunkVisitor.atomNode(ChunkVisitor.java:154)
	at com.cloudbees.workflow.rest.external.ChunkVisitor.chunkEnd(ChunkVisitor.java:141)
	at org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner.fireVisitChunkCallbacks(ForkScanner.java:735)
	at org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner.visitSimpleChunks(ForkScanner.java:769)
	at org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner.visitSimpleChunks(ForkScanner.java:633)
	at com.cloudbees.workflow.rest.external.RunExt.createNew(RunExt.java:321)
	at com.cloudbees.workflow.rest.external.RunExt.create(RunExt.java:309)
	at com.cloudbees.workflow.rest.external.JobExt.create(JobExt.java:131)
	at com.cloudbees.workflow.rest.endpoints.JobAPI.doRuns(JobAPI.java:69)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
	at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
	at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:408)
	at com.cloudbees.workflow.util.ServeJson$Processor.invoke(ServeJson.java:30)
	at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26)
	at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:212)
	at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:145)
	at org.kohsuke.stapler.MetaClass$11.doDispatch(MetaClass.java:537)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
	at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:458)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
	at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:282)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:739)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:870)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:668)
	at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
	at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:243)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at io.jenkins.blueocean.ResourceCacheControl.doFilter(ResourceCacheControl.java:134)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at io.jenkins.blueocean.auth.jwt.impl.JwtAuthenticationFilter.doFilter(JwtAuthenticationFilter.java:61)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at com.smartcodeltd.jenkinsci.plugin.assetbundler.filters.LessCSS.doFilter(LessCSS.java:47)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at jenkins.metrics.impl.MetricsFilter.doFilter(MetricsFilter.java:125)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.plugins.greenballs.GreenBallFilter.doFilter(GreenBallFilter.java:59)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:128)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:64)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
	at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
	at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1340)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.Server.handle(Server.java:503)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
	at java.lang.Thread.run(Thread.java:748)

In this case, the step is being called in a custom method defined in a loaded groovy script.

Jenkinsfile

pipeline {

  ...
  stages {
    stage("Build") {
      steps {
        ...
      }
      post {
        success {
          script {
            // hack for local "shared library"
            load('ci/github-pr-coverage.groovy').compareCoverageAction()
          }
        }
      }
    }
  }
}

ci/github-pr-coverage.groovy

// https://github.com/jenkinsci/github-pr-coverage-status-plugin
def masterCoverageAction() {
  step([$class: 'MasterCoverageAction', jacocoCounterType: 'INSTRUCTION', scmVars: [GIT_URL: env.GIT_URL]])
}

def compareCoverageAction() {
  step([$class: 'CompareCoverageAction', jacocoCounterType: 'INSTRUCTION', publishResultAs: 'comment', scmVars: [GIT_URL: env.GIT_URL]])
}

return this

Step ‘Publish coverage to GitHub’ aborted due to exception

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)

Not able to change value for "Jacoco coverage counter type"

We tried to change the value for "Jacoco coverage counter type" in "Publish coverage to GitHub" from "instruction" to "Line". But it new config changes are not getting changed and it is always considering "instruction".Please advise.

MasterCoverageAction gets confused by node_modules/**/coverage.json

Some yarn packages may ship coverage.json files. These dependencies should not be considered in any coverage metrics:

bash-4.2# find . -name coverage.json
./node_modules/selenium-webdriver/node_modules/tmp/coverage/coverage.json
./node_modules/async-limiter/coverage/coverage.json
./node_modules/mocha-multi-reporters/artifacts/coverage/coverage.json

The MasterCoverageAction step gets confused by these coverage.json files, because they are not ruby SimpleCov files:

java.lang.IllegalArgumentException: Strange SimpleCov report!
Can't extract float value by JsonPath: $.metrics.covered_percent
from:
{"/Users/samuelreed/git/forks/async-throttle/index.js":{"path":"/Users/samuelreed/git/forks/async-throttle/index.js","s":{"1":1,"2":7,"3":1,"4":6,"5":6,"6":6,"7":6,"8":6,"9": ....}
    at com.github.terma.jenkins.githubprcoveragestatus.SimpleCovParser.extractValueFromPath(SimpleCovParser.java:34)
    at com.github.terma.jenkins.githubprcoveragestatus.SimpleCovParser.get(SimpleCovParser.java:26)
    at com.github.terma.jenkins.githubprcoveragestatus.GetCoverageCallable.getFloats(GetCoverageCallable.java:49)
    at com.github.terma.jenkins.githubprcoveragestatus.GetCoverageCallable.invoke(GetCoverageCallable.java:72)
    at com.github.terma.jenkins.githubprcoveragestatus.GetCoverageCallable.invoke(GetCoverageCallable.java:32)

It does not seem to be possible to configure the search patterns for the various coverage files, which makes it seemingly impossible to ignore things like node_modules files:

cov.addAll(getFloats(ws, "**/cobertura.xml", new CoberturaParser()));
cov.addAll(getFloats(ws, "**/cobertura-coverage.xml", new CoberturaParser()));
cov.addAll(getFloats(ws, "**/jacoco.xml", new JacocoParser(jacocoCounterType)));
//default for gradle
cov.addAll(getFloats(ws, "**/jacocoTestReport.xml", new JacocoParser(jacocoCounterType)));
cov.addAll(getFloats(ws, "**/clover.xml", new CloverParser()));
if (!disableSimpleCov) {
cov.addAll(getFloats(ws, "**/coverage.json", new SimpleCovParser()));
}

Feature: Support Jenkins Credentials / Oauth tokens

[Feature Request]

Currently most github plugins support authentication using the jenkins credential system with an OAUTH token as an option as well.

I am requesting

  1. Include Support to obtain credentials from Jenkins Credential Storage
  2. OAUTH token authentication

Add documentation for options including `publishResultAs`, `scmVars`, etc

Hi maintainers!

First, thanks for publishing this plugin. It's been a great help to my team's workflow.

While using this plugin, I found the README documentation pretty unhelpful because it didn't explain the available options for the plugin. In fact, the documentation does not produce the expected results in at least one case-- publishResultsAs is always defined as statusCheck throughout the README, but the screenshot at the top of the docs corresponds to publishResultsAs: 'comment'.

Additionally, scmVars is undocumented and it's not intuitive that GIT_BRANCH, GIT_COMMIT need to be provided to discover the PR.

It may be helpful to add further documentation beyond this, but these are the pain-points I discovered and only resolved by diving into the plugin source (and after many failed Jenkins jobs!)

As to a resolution, I'm happy to submit a PR to add these sections to the README if the maintainers are in support of that. Just let me know.

Jacoco version 0.8

It would be good to update the jacoco version to get eh improved features it has eg Java 9, Java 10 (0.8.1) and lombok generated support.

Feature: make configurable status check on coverage drop or add a kind of "tollerance"

Hi,

First, thanks a lot for your work in this plugin, it's very useful for my organization even if code coverage reporting is a stressful topic.

I noticed that from version 2.1.1, is present the possibility to

Fail the status check when the coverage decreased

which is great and a fair point of discussion for the proposed code in PR but sometimes the report show something like that:

9695c93b-4837-4f9c-9e21-f88660ff1e75

which generate a bit of confusion and some awful discussion. I think that the reported value is truncated but the status check is evaluated with the complete value. Maybe a solution could be:

  • evaluate the status with the same value reported in the PR
  • add the possibility to disable the commit status or configure a tollerance value in which the status check is successful or failed.

Again thanks a lot for your work!

Injecting GIT_URL and CHANGE_URL

Trying to make use of the hint you gave in README, I am still getting an error:

java.lang.UnsupportedOperationException: Can't find GIT_URL or CHANGE_URL in envs: {BRANCH_NAME=master, BUILD_DISPLAY_NAME=#31, BUILD_ID=31, BUILD_NUMBER=31, BUILD_TAG=jenkins-testci-master-31, BUILD_URL=https://jnkns-ci.tmh.cloud/job/testci/job/master/31/, CLASSPATH=, HUDSON_HOME=/var/jenkins_home, HUDSON_SERVER_COOKIE=01f6aedeea333d1f, HUDSON_URL=https://jnkns-ci.tmh.cloud/, JENKINS_HOME=/var/jenkins_home, JENKINS_SERVER_COOKIE=01f6aedeea333d1f, JENKINS_URL=https://jnkns-ci.tmh.cloud/, JOB_BASE_NAME=master, JOB_DISPLAY_URL=https://jnkns-ci.tmh.cloud/job/testci/job/master/display/redirect, JOB_NAME=testci/master, JOB_URL=https://jnkns-ci.tmh.cloud/job/testci/job/master/, RUN_CHANGES_DISPLAY_URL=https://jnkns-ci.tmh.cloud/job/testci/job/master/31/display/redirect?page=changes, RUN_DISPLAY_URL=https://jnkns-ci.tmh.cloud/job/testci/job/master/31/display/redirect}
	at com.github.terma.jenkins.githubprcoveragestatus.PrIdAndUrlUtils.getGitUrl(PrIdAndUrlUtils.java:85)
	at com.github.terma.jenkins.githubprcoveragestatus.MasterCoverageAction.perform(MasterCoverageAction.java:71)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:49)
	at hudson.security.ACL.impersonate(ACL.java:260)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(SynchronousNonBlockingStepExecution.java:46)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE

This is my pipeline:

pipeline {

  agent any

  options {
    skipDefaultCheckout()
  }
  environment {
    // calling credentials() actually sets 3 environment variables
    // GIT_HUB with  <username>:<password>
    // GIT_HUB_USER with <username>
    // GIT_HUB_PSW with <password>

    GIT_HUB = credentials('xxxx')
    DOCKER_REPO  = 'mobilityhouse'
    DOCKER_HUB   = credentials('xxxx')
    CHANGE_URL = "https://[email protected]/mobilityhouse/testci.git"
  }

  stages{
    stage('Checkout') {
      steps {
        script {
          checkout scm
          result = sh (script: "git log -1 | grep '.*\\[ci skip\\].*\\|.*\\[skip ci\\].*'", returnStatus: true)
          if (result == 0) {
              currentBuild.result = 'NOT_BUILT'
              error("SKIPPING BUILD ...")
          }
        }
      }
    }
    // slaves are built on top of Debian ... or at least I thought so ...
    stage('Prepare Environment') {
      steps {
        sh 'pip3 install -r requirements_dev.txt'
        script {
          currentBuild.result = 'SUCCESS'
        }
      }
    }

    /* currently it's not possible to run the tests in a docker
       and get the xml results ...*/
    stage('Coverage & Tests') {
      steps {
        sh 'pip3 install -e .'
        sh 'make coverage-xml'
        script {
          currentBuild.result = 'SUCCESS'
          // sh(script: 'export GIT_URL="https://[email protected]/mobilityhouse/testci.git"')
          env.CHANGE_URL = "https://[email protected]/mobilityhouse/testci.git"
        }
      }
    }

    /* stage('Test') {
      steps {
        echo 'hl'
      }
    post {
      success {
        echo 'This works!'
        }
      }
    }

    stage('Fail') {
      steps {
        sh 'ls -l /jkk'
      }
    post {
      success {
        echo 'does will never work'
        }
      failure {
        echo 'sigh!'
        }
      }

    } */
  }

    post {
        success {
              step([$class: 'MasterCoverageAction'])
              step([$class: 'CompareCoverageAction'])

        }
    }

}

Can you explain how to inject the variables?

Cobertura-coverage.xml is being parsed as SimpleCov format for some reason

My filename is cobertura-coverage.xml. Jenkins reports the following error in Record Master coverage post-build action.

java.lang.IllegalArgumentException: Strange SimpleCov report!
Can't extract float value by JsonPath: $.metrics.covered_percent

Call stack:
at com.github.terma.jenkins.githubprcoveragestatus.SimpleCovParser.extractValueFromPath(SimpleCovParser.java:34)
at com.github.terma.jenkins.githubprcoveragestatus.SimpleCovParser.get(SimpleCovParser.java:26)
at com.github.terma.jenkins.githubprcoveragestatus.GetCoverageCallable.getFloats(GetCoverageCallable.java:40)
at com.github.terma.jenkins.githubprcoveragestatus.GetCoverageCallable.invoke(GetCoverageCallable.java:58)
at com.github.terma.jenkins.githubprcoveragestatus.GetCoverageCallable.invoke(GetCoverageCallable.java:32)
....

Build step 'Record Master Coverage' marked build as failure

Feature: Make commit status context configurable

The Github commit status is currently hard coded to test-coverage-plugin. It would be great if that is a optional parameter when calling the plugin. For example:

step([
    $class: 'CompareCoverageAction', 
    jacocoCounterType: 'INSTRUCTION', 
    publishResultAs: 'statusCheck', 
    statusContext: 'my-custom-commit-status-context', 
    scmVars: [GIT_URL: env.GIT_URL]
])

Plugin incompatibility with newer Sonar versions

Version report

2.1.1

Jenkins and plugins versions report:

Jenkins: 2.2.49.2
Sonar: 8.4.1
  • What Operating System are you using (both controller, and any agents involved in the problem)?
Linux 3.10.0-1127.19.1.el7.x86_64

Reproduction steps

Setup Publish of coverage using plugin

Results

Expected result:

It should be able to find the master coverage from Sonar

Actual result:

The API used to search for projects is /api/projects/index?search= which is no longer supported by sonar. The plugin fails to find the master coverage from sonar.

{
  "errors": [
    {
      "msg": "Unknown url : /api/projects/index"
    }
  ]
}

Jenkins output

00:23:28  [GitHub PR Status] start
00:23:28  [GitHub PR Status] getting master coverage...
00:23:28  take master coverage from sonar by token
00:23:29  Getting coverage for Git Repo URL: <git repo path> by repo name: <git project name>
00:23:29  Failed to get master coverage for <git repo path>
00:23:29  Exception message 'com.github.terma.jenkins.githubprcoveragestatus.SonarMasterCoverageRepository$SonarProjectRetrievalException: failed to search for sonar project <git project name> - Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
00:23:29   at [Source: (org.apache.commons.httpclient.AutoCloseInputStream); line: 1, column: 2]'
00:23:29  com.github.terma.jenkins.githubprcoveragestatus.SonarMasterCoverageRepository$SonarProjectRetrievalException: failed to search for sonar project profile-diagnostics - Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

Merge some fixes please

ok so lots of issues going on with this plugin - to keep it short - if you follow the documentation - it doesnt work.

please merge the pending fixes....

GitHub Personal Access token getting invalidated

we are using this plugin along with the Github Organization jobs to accomplish automated PR builds.

the issue we are having is that somewhere in the communication with this configuration the Github PATs is getting invalidated.
we have a simple service account with a PAT token on Github Enterprise set up for processing Pull requests.

periodically when trying to upload coverage reports

[GitHub PR Status] start
[GitHub PR Status] getting master coverage...
use default coverage repo

results in

GitHub has been notified of this commit’s build result

java.io.IOException: Server returned HTTP response code: 401 for URL: https://github.digitalglobe.com/api/v3/user
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1900)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:352)
	at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:69)
	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:400)
Caused: java.io.IOException: Server returned HTTP response code: 401 for URL: https://github.digitalglobe.com/api/v3/user
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1950)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1945)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1944)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1514)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
	at org.kohsuke.github.GitHubHttpUrlConnectionClient$HttpURLConnectionResponseInfo.bodyStream(GitHubHttpUrlConnectionClient.java:197)
	at org.kohsuke.github.GitHubResponse$ResponseInfo.getBodyAsString(GitHubResponse.java:326)
	at org.kohsuke.github.GitHubResponse.parseBody(GitHubResponse.java:91)
	at org.kohsuke.github.GitHubClient.lambda$fetch$0(GitHubClient.java:145)
	at org.kohsuke.github.GitHubClient.createResponse(GitHubClient.java:461)
	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:412)
Caused: org.kohsuke.github.HttpException: {"message":"Bad credentials","documentation_url":"https://docs.github.com/enterprise/2.22/rest"}
	at org.kohsuke.github.GitHubClient.interpretApiError(GitHubClient.java:495)
	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:420)
	at org.kohsuke.github.GitHubClient.fetch(GitHubClient.java:145)
	at org.kohsuke.github.GitHubClient.<init>(GitHubClient.java:134)
	at org.kohsuke.github.GitHubHttpUrlConnectionClient.<init>(GitHubHttpUrlConnectionClient.java:45)
	at org.kohsuke.github.GitHub.<init>(GitHub.java:115)
	at org.kohsuke.github.GitHubBuilder.build(GitHubBuilder.java:423)
	at org.kohsuke.github.GitHub.connectToEnterpriseWithOAuth(GitHub.java:178)
	at org.kohsuke.github.GitHub.connectToEnterprise(GitHub.java:157)
	at com.github.terma.jenkins.githubprcoveragestatus.GitHubPullRequestRepository.getGitHub(GitHubPullRequestRepository.java:68)
	at com.github.terma.jenkins.githubprcoveragestatus.GitHubPullRequestRepository.getGitHubRepository(GitHubPullRequestRepository.java:39)
	at com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction.perform(CompareCoverageAction.java:137)
	at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:99)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:69)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE

The Declaritive pipeline looks like this

        stage('PR Coverage to Github') {
            when { allOf {not { branch 'master' }; expression { return env.CHANGE_ID != null }} }
            steps {
                script {
                    currentBuild.result = 'SUCCESS'
                 }
                step([$class: 'CompareCoverageAction',
                              publishResultAs: 'statusCheck',
                              scmVars: [GIT_URL: '$GIT_URL']])
            }
        }

Digging around Github logs hasnt produced anything useful as of yet.

Compare coverage against PR base branch instead of master

Not all of our pull requests are opened against a single branch; sometimes we create pull requests against release/hotfix branches. When we do, the coverage change report is not meaningful. What would it take to always compare coverage in a PR branch against the PR's base branch instead?

Unable to communicate with Github: Error: Step ‘Publish coverage to GitHub’ aborted due to exception

We're using Github Pull Request Builder to trigger checks against our pull requests on our github enterprise repositories. We got the checks working and passing, and now we're going through and trying to incorporate code coverage onto the PR's.

We host jenkins via HTTPS along with our github enterprise. When the test pass and we kickoff the post build action we get the following error report:

ERROR: Step ‘Publish coverage to GitHub’ aborted due to exception: 
java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 503 Service Unavailable"
	at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2142)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:347)
	at org.kohsuke.github.Requester.parse(Requester.java:602)
Caused: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 503 Service Unavailable"
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1944)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1939)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1938)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1508)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
	at org.kohsuke.github.Requester.parse(Requester.java:612)
Caused: org.kohsuke.github.HttpException: Server returned HTTP response code: 503, message: 'Service Unavailable' for URL: *******
	at org.kohsuke.github.Requester.parse(Requester.java:633)
	at org.kohsuke.github.Requester.parse(Requester.java:594)
	at org.kohsuke.github.Requester._to(Requester.java:272)
	at org.kohsuke.github.Requester.to(Requester.java:234)
	at org.kohsuke.github.GitHub.getMyself(GitHub.java:384)
	at org.kohsuke.github.GitHub.<init>(GitHub.java:158)
	at org.kohsuke.github.GitHubBuilder.build(GitHubBuilder.java:207)
	at org.kohsuke.github.GitHub.connectToEnterpriseWithOAuth(GitHub.java:188)
	at org.kohsuke.github.GitHub.connectToEnterprise(GitHub.java:176)
	at com.github.terma.jenkins.githubprcoveragestatus.GitHubPullRequestRepository.getGitHub(GitHubPullRequestRepository.java:71)
	at com.github.terma.jenkins.githubprcoveragestatus.GitHubPullRequestRepository.getGitHubRepository(GitHubPullRequestRepository.java:42)
	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)
Notifying upstream projects of job completion
Unable to get pull request builder trigger!!

It seems that however the code coverage plugin and the pull request check plugin are interacting, the code coverage plugin isn't able to properly reach out to our GHE instance, but the builder works fine without this plugin.

We noticed a similar error for GithubPullRequestBuilder before we provisioned the no proxy host to add our github enterprise url.

Any ideas as to what is causing this issue?

Same Coverage for Pull Request and Master Build

I am using getting the same coverage for master and pull request,

here is my jenkins pipeline syntax

`
def fullBranchUrl(branchName) { return "${scm.getUserRemoteConfigs()[0].getUrl()}/tree/$branchName" }

timestamps {
node(label: 'master') {
stage('Checkout Git Repo') {
....
....
}
stage('Test stage') {
echo "test stage in progress"
// run tests here and generate coverage report
}
stage('Archive and Record Tests') {
if (fileExists('output/coverage/jest/cobertura-coverage.xml')) {
archiveArtifacts 'output/coverage/jest/cobertura-coverage.xml'
cobertura coberturaReportFile: 'output/coverage/jest/cobertura-coverage.xml'
}
else {
echo 'XML report were not created'
}
}
stage('Record Coverage') {
if (env.CHANGE_ID == null) {
currentBuild.result = 'SUCCESS'
step([$class: 'MasterCoverageAction', scmVars: [GIT_URL: env.CHANGE_URL]])
}
else if (env.CHANGE_ID != null) {
currentBuild.result = 'SUCCESS'
step([$class: 'MasterCoverageAction', scmVars: [GIT_URL:env. CHANGE_URL]])
step([$class: 'CompareCoverageAction', publishResultAs: 'comment', scmVars: [GIT_URL: fullBranchUrl(env.CHANGE_URL.) ]])
}

    }
    stage('Clean Workspace') {
        cleanWs notFailBuild: true
    }
}

}
`

and what i get in the build report is

19:53:16 Master coverage +70% [Pipeline] step 19:53:16 [GitHub PR Status] start 19:53:16 [GitHub PR Status] getting master coverage... 19:53:16 use default coverage repo 19:53:17 [GitHub PR Status] master coverage: 0.69535 19:53:17 [GitHub PR Status] collecting coverage... 19:53:17 [GitHub PR Status] build coverage: 0.69535 19:53:17 [GitHub PR Status] Coverage 70% changed 0.0% vs master 70% 19:53:17 [GitHub PR Status] publishing result as comment

looking at the readme and docs i couldn't find any solution for that. I want to know how master coverage being generated same as the PR build although the coverage in master branch is different.

Am i missing something here ? any kind of clarifications or help would be really nice

status check reporting success on coverage drop

Im getting a successful status check reported in Github when the coverage drops, im expecting a failed check.

[GitHub PR Status] master coverage: 0.496
[GitHub PR Status] collecting coverage...
[GitHub PR Status] build coverage: 0.47907975
[GitHub PR Status] Coverage 48% changed -1.69% vs master 50%
[GitHub PR Status] publishing result as status check
image

pipeline stage
stage('PR Coverage to Github') {
when { allOf {not { branch 'master' }; expression { return env.CHANGE_ID != null }} }
steps {
script {
currentBuild.result = 'SUCCESS'
}
step([$class: 'CompareCoverageAction',
publishResultAs: 'statusCheck',
scmVars: [GIT_URL: env.GIT_URL]])
}
}

Constantly getting 0% master coverage on non PR branches

Hi,
Here is my scripted pipeline code:

def executeChecks() {
    if (params.SKIP_TESTS) {
        echo('Skipping Test stage')
        return
    }   

    stage('Test') {
        executeCompatibilityChecks()
        executeUnitTests()
    }   

    stage('Record Coverage') {                                                                                                                                                                                                                                 
        if ( env.DEFAULT_BRANCH == env.GIT_LOCAL_BRANCH ) { 
            currentBuild.result = 'SUCCESS'
            step([$class: 'MasterCoverageAction', scmVars: [GIT_URL: env.GIT_URL]])
        }   
    }   

    stage('PR Coverage to Github') {
        if ( GH.isOnPullRequest() && env.CHANGE_ID != null) {
            currentBuild.result = 'SUCCESS'
            step([$class: 'CompareCoverageAction', scmVars: [GIT_URL: env.GIT_URL]])
        }   
    }   
}

Branch is release/*
Build logs:

[Pipeline] jacoco
21:17:33 [JaCoCo plugin] Collecting JaCoCo coverage data...
21:17:33 [JaCoCo plugin] **/build/jacoco/**.exec;**/build/classes/java/main;**/src/main/java, **/src/java; locations are configured
21:17:34 [JaCoCo plugin] Number of found exec files for pattern **/build/jacoco/**.exec: 1
21:17:34 [JaCoCo plugin] Saving matched execfiles:  /home/jenkins/agent/workspace/ci_app-tcb-api_release_9.13-U24S2KQQ5AFJ2IBZKZG6SAD7MRNMKAGI2YZRCUB7N5KTTGC2QFSA/build/jacoco/test.exec
21:17:34 [JaCoCo plugin] Saving matched class directories for class-pattern: **/build/classes/java/main: 
21:17:34 [JaCoCo plugin]  - /home/jenkins/agent/workspace/ci_app-tcb-api_release_9.13-U24S2KQQ5AFJ2IBZKZG6SAD7MRNMKAGI2YZRCUB7N5KTTGC2QFSA/build/classes/java/main 314 files
21:17:35 [JaCoCo plugin] Saving matched source directories for source-pattern: **/src/main/java, **/src/java: 
21:17:35 [JaCoCo plugin] - /home/jenkins/agent/workspace/ci_app-tcb-api_release_9.13-U24S2KQQ5AFJ2IBZKZG6SAD7MRNMKAGI2YZRCUB7N5KTTGC2QFSA/src/java 259 files
21:17:35 [JaCoCo plugin] Loading inclusions files..
21:17:35 [JaCoCo plugin] inclusions: [**/*.class]
21:17:35 [JaCoCo plugin] exclusions: []
21:17:35 [JaCoCo plugin] Thresholds: JacocoHealthReportThresholds [minClass=0, maxClass=80, minMethod=0, maxMethod=80, minLine=0, maxLine=80, minBranch=0, maxBranch=0, minInstruction=0, maxInstruction=0, minComplexity=0, maxComplexity=0]
21:17:35 [JaCoCo plugin] Publishing the results..
21:17:35 [JaCoCo plugin] Loading packages..
21:17:35 [JaCoCo plugin] Done.
21:17:35 [JaCoCo plugin] Overall coverage: class: 20, method: 22, line: 23, branch: 18, instruction: 24
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Record Coverage)
[Pipeline] step
21:17:36 Master coverage 0%
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (PR Coverage to Github)
[Pipeline] }
[Pipeline] // stage

no public field ‘sonarLogin’ found in class com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction

Can we get some attention on this plugin -

Plugin broke again today with latest Jenkins updates.

java.lang.UnsupportedOperationException: no public field ‘sonarLogin’ (or getter method) found in class com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction

—T

LOG…
failed to uncoerce com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction@5d79a38
java.lang.UnsupportedOperationException: no public field ‘sonarLogin’ (or getter method) found in class com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction
at org.jenkinsci.plugins.structs.describable.DescribableParameter.getValue(DescribableParameter.java:161)
at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:142)
at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2(DescribableModel.java:655)
at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2_(DescribableModel.java:752)
at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:196)
at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:142)
at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2(DescribableModel.java:655)
at org.jenkinsci.plugins.workflow.actions.ArgumentsAction.resolve(ArgumentsAction.java:306)
at org.jenkinsci.plugins.workflow.actions.ArgumentsAction.getResolvedArguments(ArgumentsAction.java:293)
at org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode.getDelegateType(StepAtomNode.java:134)
at org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode.effectiveDisplayName(StepAtomNode.java:90)
at org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode.getTypeDisplayName(StepAtomNode.java:102)
at org.jenkinsci.plugins.workflow.graph.FlowNode.getDisplayName(FlowNode.java:257)
at io.jenkins.blueocean.rest.impl.pipeline.PipelineNodeUtil.getDisplayName(PipelineNodeUtil.java:58)
at io.jenkins.blueocean.rest.impl.pipeline.FlowNodeWrapper.(FlowNodeWrapper.java:87)
at io.jenkins.blueocean.rest.impl.pipeline.PipelineStepVisitor.atomNode(PipelineStepVisitor.java:193)
at org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner.fireVisitChunkCallbacks(ForkScanner.java:749)
at org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner.visitSimpleChunks(ForkScanner.java:767)
at org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner.visitSimpleChunks(ForkScanner.java:631)
at io.jenkins.blueocean.rest.impl.pipeline.PipelineNodeGraphVisitor.getPipelineNodeSteps(PipelineNodeGraphVisitor.java:618)
at io.jenkins.blueocean.rest.impl.pipeline.PipelineStepContainerImpl.iterator(PipelineStepContainerImpl.java:43)
at io.jenkins.blueocean.rest.model.Container.iterator(Container.java:39)
at io.jenkins.blueocean.rest.pageable.PagedResponse$Processor$1.generateResponse(PagedResponse.java:57)
at org.kohsuke.stapler.HttpResponseRenderer$Default.handleHttpResponse(HttpResponseRenderer.java:124)
at org.kohsuke.stapler.HttpResponseRenderer$Default.generateResponse(HttpResponseRenderer.java:69)
at org.kohsuke.stapler.Function.renderResponse(Function.java:164)
at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:147)
at org.kohsuke.stapler.IndexDispatcher.dispatch(IndexDispatcher.java:27)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$2.doDispatch(MetaClass.java:220)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:457)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$2.doDispatch(MetaClass.java:220)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:457)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$2.doDispatch(MetaClass.java:220)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:457)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$2.doDispatch(MetaClass.java:220)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:457)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$2.doDispatch(MetaClass.java:220)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:457)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$2.doDispatch(MetaClass.java:220)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:457)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:457)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:457)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:735)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:457)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:694)
at org.kohsuke.stapler.Stapler.service(Stapler.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:763)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1631)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:248)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at jenkins.security.ResourceDomainFilter.doFilter(ResourceDomainFilter.java:76)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:129)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at io.jenkins.blueocean.ResourceCacheControl.doFilter(ResourceCacheControl.java:134)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at io.jenkins.blueocean.auth.jwt.impl.JwtAuthenticationFilter.doFilter(JwtAuthenticationFilter.java:60)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:159)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:51)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at jenkins.security.SuspiciousRequestFilter.doFilter(SuspiciousRequestFilter.java:36)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:549)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1610)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1369)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:489)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1580)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1284)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.Server.handle(Server.java:501)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:272)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
at java.lang.Thread.run(Thread.java:748)

Polish Readme

With the current version of the Readme it's quite hard to integrate the plugin if you aren't using the PullRequestBuilder Plugin.

For example there are some edge cases like the GITHUB_URL and CHANGE_ID environment variables which aren't mentioned at all in the Readme currently.

Implement support for custom location of jacoco-report file (Android support)

I have an android app for which I would like to have code coverage reports, unfortunately this doesn't work becuase jacoco-android-plugin generates report with different filename for every flavor it's running against, i.e. {project}\build\reports\jacoco\jacocoTestDevDebugUnitTestReport\jacocoTestDevDebugUnitTestReport.xml.

As far I see, current implementation is only looking for **/jacoco.xml and **/jacocoTestReport.xml


cov.addAll(getFloats(ws, "**/jacocoTestReport.xml", new JacocoParser())); //default for gradle

As the result I see 0% (0.0%) vs master 0% in my PRs.

We need a way to specify custom location of jacoco-report files

java.lang.IllegalArgumentException: Strange Jacoco report!

Getting this error why scanning for pull request code coverage...

[GitHub PR Status] collecting coverage...
ERROR: Build step failed with exception
java.lang.IllegalArgumentException: Strange Jacoco report!
File path: /var/jenkins_home/jobs/pullrq-build-RELEASE/workspace@2/cpp-ui/language-hook/target/site/jacoco/jacoco.xml
Can't extract float value by XPath: /report/counter[@type='LINE']/@missed
from:

Sonar: Correct master metric (at least for Jacoco)

In Sonar, I've got the following metrics displayed:
Coverage: 64.8%
Line Coverage: 72.8%
Condition Coverage: 38.8%

Here, it is grabbing the master as "coverage" which gets us 64.8%.
Then, we calculate the current coverage via the JacocoParser, which is just calculating off of line coverage, thus I end up comparing "coverage" versus "line coverage"...

Would it make sense to be able to select which metric to use for:

  • parsing jacoco (instruction, line, or branch)
  • pulling from sonar (coverage (aka instruction), line, or condition (aka branch)

Thanks.

Discover PR URL via GH API to support BRANCH builds in multi-branch

We're using the Multibranch plugin but can't use PR builds for various reasons, so we only have branch builds turned on. It which works well in github, commits get the green checkmarks, PRs get approved for merging etc....
Except this plugin is broken because it expects CHANGE_URL to be set. It would be nice to have an option to use https://developer.github.com/v3/pulls/#list-pull-requests for branch builds to discover associated PRs and still get the same functionality.

It looks like it's not that much work and may contribute a PR for this.

Unknown parameter(s) found for class type 'com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction': jacocoCounterType

We see:

Unknown parameter(s) found for class type 'com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction': jacocoCounterType

when using documented approach from README.md:

if ('SUCCESS' == currentBuild.currentResult) {
    currentBuild.result = 'SUCCESS'
    step([$class: 'CompareCoverageAction', jacocoCounterType: 'INSTRUCTION', publishResultAs: 'comment', scmVars: [GIT_URL: env.GIT_URL]])
}

If we simply replace jacocoCounterType with jacocoCoverageCounter (reference in CompareCoverageAction class) the warning is not shown.

Note: problem is only with CompareCoverageAction. All works as expected for MasterCoverageAction though.

I assume if CompareCoverageAction class is changed it might break current setup that some are using. It makes sense to fix the README.md though since currently it's a bug in documentation. Please fix.

Remove jdk-tool implicit plugin dependency

This plugin has an implicit dependency on jdk-tool for installing the Oracle JDK. Given Oracle's recent hostile licensing changes, it seems detrimental to have plugins depend on it. I think a new release of this plugin against a later version of jenkins (after jdk-tool was split out of the core) is all that's needed.

Replacement vs creation of comments

Hi,

Would it be possible to replace the previous comment instead of creating one each time ?

screen shot 2018-01-15 at 10 31 48 am

I would like to avoid this behavior.

Thanks !

GitUtils#getUserRepo logic is very strictive

While working with this plugin on jenkins, I found that one of its key logic, GitUtils#getUserRepo has unrealistic assumptions on the git url, in its regex matching:

public static final Pattern HTTP_GITHUB_USER_REPO_PATTERN = Pattern.compile("^(http[s]?://[^/]*)/([^/]*/[^/]*).*");

For my working repository, the GIT_URL set by the Github Plugin is https://github.com/apache/kafka/ which cause the github retrieve to fail:

https://github.com/kohsuke/github-api/blob/master/src/main/java/org/kohsuke/github/GitHub.java#L443

And here is the stack trace, note that the parsed repoName is //github.com/apache/kafka not the expected apache/kafka.

20:21:24 java.io.FileNotFoundException: https://api.github.com/repos//
20:21:24 	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1890)
...
20:21:24 Caused: java.io.IOException: Could not retrieve GitHub repository named //github.com/apache/kafka (Do you have properly set 'GitHub project' field in job configuration?)
20:21:24 	at com.github.terma.jenkins.githubprcoveragestatus.GitHubPullRequestRepository.getGitHubRepository(GitHubPullRequestRepository.java:59)
20:21:24 	at com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction.perform(CompareCoverageAction.java:98)
20:21:24 	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
20:21:24 	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
20:21:24 	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
20:21:24 	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
20:21:24 	at hudson.model.Build$BuildExecution.post2(Build.java:186)
20:21:24 	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
20:21:24 	at hudson.model.Run.execute(Run.java:1749)
20:21:24 	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
20:21:24 	at hudson.model.ResourceController.execute(ResourceController.java:97)
20:21:24 	at hudson.model.Executor.run(Executor.java:421)

As a reference, this is the configuration job that I'm experimenting:

https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/configure

Can't find master coverage repository - even though I successfully ran the report

This is the output:

[GitHub PR Status] start
[GitHub PR Status] getting master coverage...
use default coverage repo
Can't find master coverage repository: https://github.com/xxx/testci/pull/8 in stored: {https://github.com/myorga/testci/pull/5=0.6923, https://github.com/xxx/testci/pull/6=0.6923, https://****@github.com/myorga/testci.git=0.5385, https://github.com/xxx/testci/pull/7=0.5385}
Make sure that you have run build with step: Record Master Coverage
[GitHub PR Status] master coverage: 0.0
[GitHub PR Status] collecting coverage...
[GitHub PR Status] build coverage: 0.6923
[GitHub PR Status] Coverage 69% changed +69.23% vs master 0%

On the master branch the output is:

[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] script
[Pipeline] {
[Pipeline] step
Master coverage +54%
[Pipeline] echo
hura!
[Pipeline] }

This is my current pipeline:

pipeline {

  agent any

  options {
    skipDefaultCheckout()
  }
  environment {
    // calling credentials() actually sets 3 environment variables
    // GIT_HUB with  <username>:<password>
    // GIT_HUB_USER with <username>
    // GIT_HUB_PSW with <password>

    GIT_HUB = credentials('xxx')
    DOCKER_REPO  = 'xxx'
    DOCKER_HUB   = credentials('xxx')
    K8S = credentials('xxx-key') // get the credential for k8s
    GIT_URL_PROPERTY = "https://github.com/xxx/testci.git"
  }

  stages{
    stage('Checkout') {
      steps {
        script {
          checkout scm
          result = sh (script: "git log -1 | grep '.*\\[ci skip\\].*\\|.*\\[skip ci\\].*'", returnStatus: true)
          if (result == 0) {
              currentBuild.result = 'NOT_BUILT'
              error("SKIPPING BUILD ...")
          }
        }
      }
    }
    // slaves are built on top of Debian ... or at least I thought so ...
    stage('Prepare Environment') {
      steps {
        sh 'cat /etc/os-release'
        sh 'echo  $PATH'
        sh 'whoami'
        sh 'ls /usr/bin/pip3'
        sh 'pip3 --version'
        sh 'pip3 install -r requirements_dev.txt'
        script {
          currentBuild.result = 'SUCCESS'
        }
      }
    }

    /* currently it's not possible to run the tests in a docker
       and get the xml results ...

       For the coverage reporting make sure you jenkins installation has
       https://github.com/jenkinsci/github-pr-coverage-status-plugin
       */
    stage('Coverage & Tests') {
      steps {
        sh 'pip3 install -e .'
        sh 'make coverage-xml'
        script {
          currentBuild.result = 'SUCCESS'
          try {
              echo "In PR"
              //step([$class: 'MasterCoverageAction',
              //    scmVars:
              //      [GIT_URL:
              //       "https://github.com/myorga/testci.git",]
              //  ])
             step([$class: 'CompareCoverageAction'])
          } catch (error) {
            echo "Not in PR"
          }
        }
      }
    }
    stage('Deploy Staging') {
      when {
        expression {
          return env.BRANCH_NAME == 'develop'
        }
      }

      steps {
        sh '....'
      }
    }
    /* stage('Test') {
      steps {
        echo 'hl'
      }
    post {
      success {
        echo 'This works!'
        }
      }
    }

    stage('Fail') {
      steps {
        sh 'ls -l /jkk'
      }
    post {
      success {
        echo 'does will never work'
        }
      failure {
        echo 'sigh!'
        }
      }

    } */
  }

    post {
        success {
           script {
              if (env.BRANCH_NAME == 'master') {
              step([$class: 'MasterCoverageAction',
                  scmVars:
                    [GIT_URL:
                     "https://github.com/xxx/testci.git",]
                ])
              echo 'hura!'
              }
           }
        }
    }
}

I would more than appreciate a hint how to get the reporting properly working ...

Support rate_limit endpoint bypass

The rate_limit endpoint is pinged before any authorization, so for private repos with SSO/SAML, it appears this plugin can't be used.

An option to bypass this check and use a default rate would be nice.

Support Configuration as code plugin

This plugin doesn't seem to support casc.

Config json schema of this plugin doesn't look right
image

also, configuration variables can't be set.

2019-11-14 09:23:38.965+0000 [id=19]    SEVERE  hudson.util.BootFailure#publish: Failed to initialize Jenkins
io.jenkins.plugins.casc.ConfiguratorException: Invalid configuration elements for type class com.github.terma.jenkins.githubprcoveragestatus.Configuration$ConfigurationDescriptor : personalAccessToken,jenkinsUrl.
Available attributes : 
        at io.jenkins.plugins.casc.BaseConfigurator.handleUnknown(BaseConfigurator.java:377)
        at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:366)
        at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:287)
        at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:352)
        at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:287)
        at io.jenkins.plugins.casc.ConfigurationAsCode.lambda$checkWith$7(ConfigurationAsCode.java:716)
        at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:666)
Caused: io.jenkins.plugins.casc.ConfiguratorException: unclassified: error configuring 'unclassified' with class io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator configurator
        at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:672)
        at io.jenkins.plugins.casc.ConfigurationAsCode.checkWith(ConfigurationAsCode.java:716)
        at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:701)
        at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:592)
        at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:281)
        at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:273)
Caused: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
Caused: java.lang.Error
        at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)
        at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1118)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused: org.jvnet.hudson.reactor.ReactorException
        at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
        at jenkins.InitReactorRunner.run(InitReactorRunner.java:48)
        at jenkins.model.Jenkins.executeReactor(Jenkins.java:1152)
        at jenkins.model.Jenkins.<init>(Jenkins.java:959)
        at hudson.model.Hudson.<init>(Hudson.java:85)
        at hudson.model.Hudson.<init>(Hudson.java:81)
        at hudson.WebAppMain$3.run(WebAppMain.java:233)
Caused: hudson.util.HudsonFailedToLoad
        at hudson.WebAppMain$3.run(WebAppMain.java:250)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.