mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-11-28 08:49:44 +02:00
Cleanup
This commit is contained in:
parent
58bd5ce7fc
commit
05fe2fb758
@ -8,7 +8,7 @@ class WhitesourceConfigurationHelper implements Serializable {
|
||||
|
||||
private static def SCALA_CONTENT_KEY = "@__content"
|
||||
|
||||
static def extendUAConfigurationFile(script, config, path) {
|
||||
static def extendUAConfigurationFile(script, utils, config, path) {
|
||||
def mapping = []
|
||||
def parsingClosure = { fileReadPath -> return script.readProperties (file: fileReadPath) }
|
||||
def serializationClosure = { configuration -> serializeUAConfig(configuration) }
|
||||
@ -78,10 +78,10 @@ class WhitesourceConfigurationHelper implements Serializable {
|
||||
break
|
||||
}
|
||||
|
||||
rewriteConfiguration(script, config, mapping, suffix, path, inputFile, targetFile, parsingClosure, serializationClosure)
|
||||
rewriteConfiguration(script, utils, config, mapping, suffix, path, inputFile, targetFile, parsingClosure, serializationClosure)
|
||||
}
|
||||
|
||||
static def extendConfigurationFile(script, config, path) {
|
||||
static def extendConfigurationFile(script, utils, config, path) {
|
||||
def mapping = [:]
|
||||
def parsingClosure
|
||||
def serializationClosure
|
||||
@ -134,10 +134,10 @@ class WhitesourceConfigurationHelper implements Serializable {
|
||||
break
|
||||
}
|
||||
|
||||
rewriteConfiguration(script, config, mapping, suffix, path, inputFile, targetFile, parsingClosure, serializationClosure)
|
||||
rewriteConfiguration(script, utils, config, mapping, suffix, path, inputFile, targetFile, parsingClosure, serializationClosure)
|
||||
}
|
||||
|
||||
static private def rewriteConfiguration(script, config, mapping, suffix, path, inputFile, targetFile, parsingClosure, serializationClosure) {
|
||||
static private def rewriteConfiguration(script, utils, config, mapping, suffix, path, inputFile, targetFile, parsingClosure, serializationClosure) {
|
||||
def inputFilePath = "${path}${inputFile}"
|
||||
def outputFilePath = "${path}${targetFile}"
|
||||
def moduleSpecificFile = parsingClosure(inputFilePath)
|
||||
@ -162,7 +162,7 @@ class WhitesourceConfigurationHelper implements Serializable {
|
||||
script.writeFile file: outputFilePath, text: output
|
||||
if(config.stashContent && config.stashContent.size() > 0) {
|
||||
def stashName = "modified whitesource config ${suffix}".toString()
|
||||
new Utils().stashWithMessage (
|
||||
utils.stashWithMessage (
|
||||
stashName,
|
||||
"Stashing modified Whitesource configuration",
|
||||
outputFilePath.replaceFirst('\\./', '')
|
||||
|
@ -69,7 +69,7 @@ class WhiteSourceConfigurationHelperTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testExtendConfigurationFileUnifiedAgent() {
|
||||
WhitesourceConfigurationHelper.extendConfigurationFile(nullScript, [scanType: 'unifiedAgent', configFilePath: './config', orgToken: 'abcd', productName: 'name', productToken: '1234', userKey: '0000'], "./")
|
||||
WhitesourceConfigurationHelper.extendConfigurationFile(nullScript, utils, [scanType: 'unifiedAgent', configFilePath: './config', orgToken: 'abcd', productName: 'name', productToken: '1234', userKey: '0000'], "./")
|
||||
assertThat(jwfr.files['./config.c92a71303bcc841344e07d1bf49d1f9b'], containsString("apiKey=abcd"))
|
||||
assertThat(jwfr.files['./config.c92a71303bcc841344e07d1bf49d1f9b'], containsString("productName=name"))
|
||||
assertThat(jwfr.files['./config.c92a71303bcc841344e07d1bf49d1f9b'], containsString("productToken=1234"))
|
||||
@ -78,7 +78,7 @@ class WhiteSourceConfigurationHelperTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testExtendConfigurationFileNpm() {
|
||||
WhitesourceConfigurationHelper.extendConfigurationFile(nullScript, [scanType: 'npm', configFilePath: './config', orgToken: 'abcd', productName: 'name', productToken: '1234', userKey: '0000'], "./")
|
||||
WhitesourceConfigurationHelper.extendConfigurationFile(nullScript, utils, [scanType: 'npm', configFilePath: './config', orgToken: 'abcd', productName: 'name', productToken: '1234', userKey: '0000'], "./")
|
||||
assertThat(jwfr.files['./config.c92a71303bcc841344e07d1bf49d1f9b'], containsString("\"apiKey\": \"abcd\","))
|
||||
assertThat(jwfr.files['./config.c92a71303bcc841344e07d1bf49d1f9b'], containsString("\"productName\": \"name\","))
|
||||
assertThat(jwfr.files['./config.c92a71303bcc841344e07d1bf49d1f9b'], containsString("\"productToken\": \"1234\","))
|
||||
@ -87,7 +87,7 @@ class WhiteSourceConfigurationHelperTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testExtendConfigurationFilePip() {
|
||||
WhitesourceConfigurationHelper.extendConfigurationFile(nullScript, [scanType: 'pip', configFilePath: './setup.py', orgToken: 'abcd', productName: 'name', productToken: '1234', userKey: '0000'], "./")
|
||||
WhitesourceConfigurationHelper.extendConfigurationFile(nullScript, utils, [scanType: 'pip', configFilePath: './setup.py', orgToken: 'abcd', productName: 'name', productToken: '1234', userKey: '0000'], "./")
|
||||
assertThat(jwfr.files['./setup.py.8813e60e0d9f7cacf0c414ae4964816f.py'], containsString("'org_token': 'abcd',"))
|
||||
assertThat(jwfr.files['./setup.py.8813e60e0d9f7cacf0c414ae4964816f.py'], containsString("'product_name': 'name',"))
|
||||
assertThat(jwfr.files['./setup.py.8813e60e0d9f7cacf0c414ae4964816f.py'], containsString("'product_token': '1234',"))
|
||||
@ -96,7 +96,7 @@ class WhiteSourceConfigurationHelperTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void testExtendConfigurationFileSbt() {
|
||||
WhitesourceConfigurationHelper.extendConfigurationFile(nullScript, [scanType: 'sbt', configFilePath: './build.sbt', orgToken: 'abcd', productName: 'name', productToken: '1234', userKey: '0000', agentUrl: 'http://mo-393ef744d.mo.sap.corp:8080/wsui/wspluginProxy.jsp'], "./")
|
||||
WhitesourceConfigurationHelper.extendConfigurationFile(nullScript, utils, [scanType: 'sbt', configFilePath: './build.sbt', orgToken: 'abcd', productName: 'name', productToken: '1234', userKey: '0000', agentUrl: 'http://mo-393ef744d.mo.sap.corp:8080/wsui/wspluginProxy.jsp'], "./")
|
||||
assertThat(jwfr.files['./build.sbt'], containsString("whitesourceOrgToken in ThisBuild := \"abcd\""))
|
||||
assertThat(jwfr.files['./build.sbt'], containsString("whitesourceProduct in ThisBuild := \"name\""))
|
||||
assertThat(jwfr.files['./build.sbt'], containsString("whitesourceServiceUrl in ThisBuild := uri(\"http://mo-393ef744d.mo.sap.corp:8080/wsui/wspluginProxy.jsp\")"))
|
||||
|
@ -59,7 +59,7 @@ void call(Map parameters = [:]) {
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName ?: env.STAGE_NAME, STEP_CONFIG_KEYS)
|
||||
.mixin([
|
||||
style : libraryResource('piper.css')
|
||||
style : libraryResource('piper-os.css')
|
||||
])
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.dependingOn('scanType').mixin('buildDescriptorFile')
|
||||
|
Loading…
Reference in New Issue
Block a user