Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Correct PR branch detection in code coverage (#12615)
Browse files Browse the repository at this point in the history
* Correct PR branch detection in code coverage

* Always use latest commit

* Add merge commit detection

* Add debug output

* Remove debug output
  • Loading branch information
marcoabreu committed Sep 21, 2018
1 parent e82eef9 commit 1045140
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ci/Jenkinsfile_utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,23 @@ echo ${libs} | sed -e 's/,/ /g' | xargs md5sum

def publish_test_coverage() {
// CodeCovs auto detection has trouble with our CIs PR validation due the merging strategy
lastCommitMessage = sh (script: "git log -1 --pretty=%B", returnStdout: true)
lastCommitMessage = lastCommitMessage.trim()
if (lastCommitMessage.startsWith("Merge commit '") && lastCommitMessage.endsWith("' into HEAD")) {
// Merge commit applied by Jenkins, skip that commit
GIT_COMMIT_HASH = sh (script: "git rev-parse @~", returnStdout: true)
} else {
GIT_COMMIT_HASH = sh (script: "git rev-parse @", returnStdout: true)
}

def codecovArgs = ""
if (env.CHANGE_ID != '') {
if (env.CHANGE_ID) {
// PR execution
// Take the previous commit because of our PR merge strategy that adds a temporary commit for CI
GIT_COMMIT_HASH = sh (script: "git rev-parse @~", returnStdout: true)
codecovArgs += "-B ${env.CHANGE_TARGET} " +
"-C ${GIT_COMMIT_HASH} " +
"-P ${env.CHANGE_ID} "
} else {
// Branch execution
GIT_COMMIT_HASH = sh (script: "git rev-parse @", returnStdout: true)
codecovArgs += "-B ${env.BRANCH_NAME} " +
"-C ${GIT_COMMIT_HASH} "
}
Expand Down

0 comments on commit 1045140

Please sign in to comment.