DEV Community

Pallat Anchaleechamaikorn
Pallat Anchaleechamaikorn

Posted on

5 2

ดู coverage บน Jenkins

Alt Text

ผมเห็นสิ่งนี้ตั้งแต่ตอนทำงานอยู่ที่ KBTG และเพิ่งจะได้มีโอกาสทำด้วยตัวเอง พอทำได้ก็เลยต้องจดไว้ซะหน่อย
ก่อนอื่น ต้องลง pulgin ใน Jenkins เสียก่อน 2 ตัวคือ

  1. Code Coverage API Plugin
  2. Cubertura Plugin

ตามรูป Alt Text

จากนั้นใน pipeline ให้ใช้คำสั่ง

gocov test ./... | gocov-xml > coverage.xml

โดยจะต้องลง gocov และ gocov-xml ก่อน และเพิ่ม step ใน Jenkinsfile ตามนี้

    post {
        always {
            step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: '**/coverage.xml', failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
        }
    }

แค่นี้ก็สามารถเห็น coverage สวยๆใน pipeline ได้แล้วครับ

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more