Skip to content

Instantly share code, notes, and snippets.

@petewilcock
petewilcock / convertCoverageToMarkdown.groovy
Created August 1, 2024 10:26
Jenkins Coverage Plugin Report to GitHub Comment
import groovy.json.JsonSlurper
def call() {
def coverageUrl = "${env.BUILD_URL}coverage/api/json?pretty=true"
echo "Getting ${coverageUrl}"
// Fetch the JSON coverage report with authentication
def jsonResponse = ""
withCredentials([string(credentialsId: 'jenkins-user-credential', variable: 'PASSWORD')]) {
def url = new URL(coverageUrl)
def connection = (HttpURLConnection) url.openConnection()