Compare commits
1 Commits
1.0.8.post
...
1.0.8.post
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc2f6353ac |
46
Jenkinsfile
vendored
46
Jenkinsfile
vendored
@@ -6,7 +6,11 @@
|
||||
// You should have received a copy of the license along with this
|
||||
// work. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
||||
|
||||
|
||||
import groovy.xml.XmlUtil
|
||||
import static javax.xml.xpath.XPathConstants.*
|
||||
import javax.xml.xpath.*
|
||||
import groovy.xml.DOMBuilder
|
||||
import groovy.xml.dom.DOMCategory
|
||||
|
||||
// configurable settings:
|
||||
// use to send email if workflow problem
|
||||
@@ -28,6 +32,10 @@ def _MkDocsWebURL = "dabauto--mkdocs-web.dmz.chacha.home/mkdocs-web/"
|
||||
def _MkDocsWebCredentials = "2c5b684e-3787-4b37-8aca-b3dd4a383fe2"
|
||||
def _PypiCredentials = "Pypi"
|
||||
|
||||
|
||||
def badge_coverage = addEmbeddableBadgeConfiguration(id: "coverage", subject: "unit-test coverage")
|
||||
def badge_complexity = addEmbeddableBadgeConfiguration(id: "complexity", subject: "code complexity")
|
||||
|
||||
// commands Helper: /!\ Made for GITEA /!\
|
||||
String determineRepoUserName() {
|
||||
return scm.getUserRemoteConfigs()[0].getUrl().tokenize('/')[3].split("\\.")[0]
|
||||
@@ -63,6 +71,27 @@ String ExtractBaseVersion(inVersion) {
|
||||
return matcher[0][1]
|
||||
}
|
||||
|
||||
int GetCoverageValue(String CoverageFilePath,String XPath)
|
||||
{
|
||||
File file = new File(CoverageFilePath)
|
||||
coverageReportRaw = file.getText('UTF-8')
|
||||
coverageReport = DOMBuilder.parse(new StringReader(coverageReportRaw), false, false)
|
||||
coverageReportRoot = coverageReport.documentElement
|
||||
|
||||
def xpath = XPathFactory.newInstance().newXPath()
|
||||
res = xpath.evaluate(XPath,coverageReportRoot,NUMBER)
|
||||
return res
|
||||
}
|
||||
|
||||
int GetCoverageValue_lines_valid(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@lines-valid") }
|
||||
int GetCoverageValue_lines_covered(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@lines-covered") }
|
||||
int GetCoverageValue_line_rate(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@line-rate") }
|
||||
int GetCoverageValue_branches_valid(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@branches-valid") }
|
||||
int GetCoverageValue_branches_covered(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@branches-covered") }
|
||||
int GetCoverageValue_branch_rate(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@branch-rate") }
|
||||
int GetCoverageValue_branches_complexity(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@branches-complexity") }
|
||||
|
||||
|
||||
pipeline {
|
||||
|
||||
// for Docker based build (preferable)
|
||||
@@ -400,6 +429,21 @@ pipeline {
|
||||
println unit_test_full_name__html
|
||||
unit_test_full_name__xml=findFiles(glob: "helpers-results/unit_test_full/*.xml")[0].getName()
|
||||
println unit_test_full_name__xml
|
||||
|
||||
coverage_report_path = "helpers-results/unit_test_coverage/test_coverage.xml"
|
||||
println GetCoverageValue_lines_valid(coverage_report_path)
|
||||
println GetCoverageValue_lines_covered(coverage_report_path)
|
||||
println GetCoverageValue_line_rate(coverage_report_path)
|
||||
println GetCoverageValue_branches_valid(coverage_report_path)
|
||||
println GetCoverageValue_branches_covered(coverage_report_path)
|
||||
println GetCoverageValue_branch_rate(coverage_report_path)
|
||||
println GetCoverageValue_branches_complexity(coverage_report_path)
|
||||
|
||||
full_rate = (GetCoverageValue_line_rate(coverage_report_path) + GetCoverageValue_branch_rate(coverage_report_path)) / 2
|
||||
badge_coverage.setStatus(full_rate)
|
||||
|
||||
complexity = GetCoverageValue_branches_complexity(coverage_report_path)
|
||||
badge_complexity.setStatus(complexity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user