mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-02-21 19:48:53 +02:00
refactor(protecode): handle reports inside go (#1891)
* publish artifacts * publish project report link * archive scan report * fix typo * remove obsolete reading iof result file * publish sidebar link Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
This commit is contained in:
parent
766a233c01
commit
0a02fe1fb8
@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
@ -14,6 +15,7 @@ import (
|
||||
"github.com/SAP/jenkins-library/pkg/command"
|
||||
piperDocker "github.com/SAP/jenkins-library/pkg/docker"
|
||||
"github.com/SAP/jenkins-library/pkg/log"
|
||||
StepResults "github.com/SAP/jenkins-library/pkg/piperutils"
|
||||
"github.com/SAP/jenkins-library/pkg/protecode"
|
||||
"github.com/SAP/jenkins-library/pkg/telemetry"
|
||||
)
|
||||
@ -200,6 +202,20 @@ func executeProtecodeScan(client protecode.Protecode, config *protecodeExecuteSc
|
||||
log.Entry().Debug("Write report to filesystem")
|
||||
writeReportDataToJSONFile(config, parsedResult, productID, vulns, ioutil.WriteFile)
|
||||
|
||||
// write reports JSON
|
||||
reports := []StepResults.Path{
|
||||
{Target: config.ReportFileName, Mandatory: true},
|
||||
{Target: "protecodeExecuteScan.json", Mandatory: true},
|
||||
{Target: "protecodescan_vulns.json", Mandatory: true},
|
||||
}
|
||||
// write links JSON
|
||||
links := []StepResults.Path{
|
||||
{Name: "Protecode WebUI", Target: fmt.Sprintf("%s/products/%v/", config.ServerURL, productID)},
|
||||
{Name: "Protecode Report", Target: path.Join("artifact", config.ReportFileName), Scope: "job"},
|
||||
}
|
||||
|
||||
StepResults.PersistReportsAndLinks("protecodeExecuteScan", "", reports, links)
|
||||
|
||||
return parsedResult
|
||||
}
|
||||
|
||||
|
@ -36,21 +36,13 @@ void call(Map parameters = [:]) {
|
||||
if (config.dockerCredentialsId) creds.add(file(credentialsId: config.dockerCredentialsId, variable: 'DOCKER_CONFIG'))
|
||||
|
||||
// execute step
|
||||
withCredentials(creds) {
|
||||
sh "./piper protecodeExecuteScan"
|
||||
try {
|
||||
withCredentials(creds) {
|
||||
sh "./piper protecodeExecuteScan"
|
||||
}
|
||||
} finally {
|
||||
jenkinsUtils.handleStepResults(STEP_NAME, false, false)
|
||||
}
|
||||
|
||||
def json = readJSON (file: "protecodescan_vulns.json")
|
||||
def report = readJSON (file: 'protecodeExecuteScan.json')
|
||||
|
||||
archiveArtifacts artifacts: report['target'], allowEmptyArchive: !report['mandatory']
|
||||
archiveArtifacts artifacts: "protecodeExecuteScan.json", allowEmptyArchive: false
|
||||
archiveArtifacts artifacts: "protecodescan_vulns.json", allowEmptyArchive: false
|
||||
|
||||
jenkinsUtils.removeJobSideBarLinks("artifact/${report['target']}")
|
||||
jenkinsUtils.addJobSideBarLink("artifact/${report['target']}", "Protecode Report", "images/24x24/graph.png")
|
||||
jenkinsUtils.addRunSideBarLink("artifact/${report['target']}", "Protecode Report", "images/24x24/graph.png")
|
||||
jenkinsUtils.addRunSideBarLink("${report['protecodeServerUrl']}/products/${report['productID']}/", "Protecode WebUI", "images/24x24/graph.png")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user