1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-09-16 09:26:22 +02:00

feat: add commit and pipeline to GitHub reporting (#3930)

Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com>
This commit is contained in:
Oliver Nocon
2022-08-15 07:48:22 +02:00
committed by GitHub
parent 91eb80fc68
commit 1e2f2d93e3

View File

@@ -7,6 +7,8 @@ import (
"text/template"
"time"
"github.com/SAP/jenkins-library/pkg/orchestrator"
"github.com/pkg/errors"
"golang.org/x/text/cases"
"golang.org/x/text/language"
@@ -87,6 +89,19 @@ func (v *VulnerabilityReport) ToMarkdown() ([]byte, error) {
return caser.String(s)
},
}
// only fill with orchestrator information if orchestrator can be identified properly
if provider, err := orchestrator.NewOrchestratorSpecificConfigProvider(); err == nil {
// only add information if not yet provided
if len(v.CommitID) == 0 {
v.CommitID = provider.GetCommit()
}
if len(v.PipelineLink) == 0 {
v.PipelineLink = provider.GetJobURL()
v.PipelineName = provider.GetJobName()
}
}
md := []byte{}
tmpl, err := template.New("report").Funcs(funcMap).Parse(vulnerabilityMdTemplate)
if err != nil {