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

Correct PR branch detection in code coverage #12615

Merged
merged 5 commits into from
Sep 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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