mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
Add creation capabilities for whitesource products
This commit is contained in:
parent
93b3afe67d
commit
6a907cff23
@ -256,6 +256,8 @@ steps:
|
||||
npmExecute:
|
||||
dockerImage: 'node:8-stretch'
|
||||
whitesourceExecuteScan:
|
||||
createProductFromPipeline: true
|
||||
emailAddressesOfInitialProductAdmins: []
|
||||
buildDescriptorExcludeList: []
|
||||
parallelLimit: 15
|
||||
licensingVulnerabilities: true
|
||||
|
@ -42,13 +42,40 @@ class WhitesourceOrgAdminRepository implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMetaProduct)
|
||||
script.error "[WhiteSource] Could not fetch/find requested product '${config.productName}'"
|
||||
|
||||
return foundMetaProduct
|
||||
}
|
||||
|
||||
def createProduct() {
|
||||
def requestBody = [
|
||||
requestType: "createProduct",
|
||||
orgToken: config.orgToken,
|
||||
productName: config.productName
|
||||
]
|
||||
def response = issueHttpRequest(requestBody)
|
||||
def parsedResponse = new JsonUtils().parseJsonSerializable(response.content)
|
||||
def metaInfo = parsedResponse
|
||||
|
||||
def groups = []
|
||||
def users = []
|
||||
config.emailAddressesOfInitialProductAdmins.each {
|
||||
email -> users.add(["email": config.emailOfInitialProductAdmin])
|
||||
}
|
||||
|
||||
requestBody = [
|
||||
"requestType" : "setProductAssignments",
|
||||
"productToken" : metaInfo.productToken,
|
||||
"productMembership" : ["userAssignments":[], "groupAssignments":groups],
|
||||
"productAdmins" : ["userAssignments":users],
|
||||
"alertsEmailReceivers" : ["userAssignments":[]]
|
||||
]
|
||||
issueHttpRequest(requestBody)
|
||||
|
||||
return metaInfo
|
||||
}
|
||||
|
||||
def issueHttpRequest(requestBody) {
|
||||
internalWhitesource ? internalWhitesource.httpWhitesource(requestBody) : httpWhitesource(requestBody)
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
protected def httpWhitesource(requestBody) {
|
||||
|
@ -224,8 +224,15 @@ private def triggerWhitesourceScanWithUserKey(script, config, utils, descriptorU
|
||||
void analyseWhitesourceResults(Map config, WhitesourceRepository repository, WhitesourceOrgAdminRepository orgAdminRepository) {
|
||||
if (!config.productToken) {
|
||||
def metaInfo = orgAdminRepository.fetchProductMetaInfo()
|
||||
echo "Meta Information: ${metaInfo}"
|
||||
config.productToken = metaInfo.token
|
||||
def key = "token"
|
||||
if(!metaInfo && config.createProductFromPipeline) {
|
||||
metaInfo = orgAdminRepository.createProduct()
|
||||
key = "productToken"
|
||||
} else if(!metaInfo) {
|
||||
error "[WhiteSource] Could not fetch/find requested product '${config.productName}' and automatic creation has been disabled"
|
||||
}
|
||||
echo "Meta Info: ${metaInfo}"
|
||||
config.productToken = metaInfo[key]
|
||||
}
|
||||
|
||||
def pdfName = "whitesource-riskReport.pdf"
|
||||
|
Loading…
Reference in New Issue
Block a user