Can't find master coverage repository - even though I successfully ran the report
oz123 opened this issue · 10 comments
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 ...
I am looking down the rabbit hole ...
My Jenkins configuration contains:
cat com.github.terma.jenkins.githubprcoveragestatus.Configuration.xml
<?xml version='1.0' encoding='UTF-8'?>
<com.github.terma.jenkins.githubprcoveragestatus.Configuration_-ConfigurationDescriptor plugin="github-pr-coverage-status@1.9.1">
<coverageByRepo class="concurrent-hash-map">
<entry>
<string>https://github.com/myorga/testci/pull/5</string>
<float>0.6923</float>
</entry>
<entry>
<string>https://github.com/myorga/testci/pull/6</string>
<float>0.6923</float>
</entry>
<entry>
<string>https://xxx:sekret@github.com/myorga/testci.git</string>
<float>0.5385</float>
</entry>
<entry>
<string>https://github.com/myorga/testci.git</string>
<float>0.5385</float>
</entry>
<entry>
<string>https://github.com/myorga/testci/pull/7</string>
<float>0.5385</float>
</entry>
</coverageByRepo>
<privateJenkinsPublicGitHub>false</privateJenkinsPublicGitHub>
<useSonarForMasterCoverage>false</useSonarForMasterCoverage>
<yellowThreshold>80</yellowThreshold>
<greenThreshold>90</greenThreshold>
</com.github.terma.jenkins.githubprcoveragestatus.Configuration_-ConfigurationDescriptor>
So why is it not finding the coverage report for the master ?
@oz123 according to coverageByRepo
should not contains repo URL from pull request. CompareStatus
is trying to find master repo which is actually not a master but PR URL.
Same problem here, would be great to have the fix merged.
any plan to fix this issue ?
Any plan to merge the commit?
Please merge this
I could make use of this still.
@oz123 Can you please tell me how can I use this plugin in my Jenkinsfile? I simply want to show code coverage on my PRs.