github-pr-coverage-status-plugin icon indicating copy to clipboard operation
github-pr-coverage-status-plugin copied to clipboard

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

Open oz123 opened this issue 7 years ago • 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 ...

oz123 avatar Sep 28 '17 14:09 oz123