diff --git a/resources/piper.css b/resources/piper-os.css similarity index 100% rename from resources/piper.css rename to resources/piper-os.css diff --git a/src/com/sap/piper/WhitesourceConfigurationHelper.groovy b/src/com/sap/piper/WhitesourceConfigurationHelper.groovy index be7a49a15..0a89a8c11 100644 --- a/src/com/sap/piper/WhitesourceConfigurationHelper.groovy +++ b/src/com/sap/piper/WhitesourceConfigurationHelper.groovy @@ -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('\\./', '') diff --git a/test/groovy/com/sap/piper/WhiteSourceConfigurationHelperTest.groovy b/test/groovy/com/sap/piper/WhiteSourceConfigurationHelperTest.groovy index 01c802604..1012cc0c1 100644 --- a/test/groovy/com/sap/piper/WhiteSourceConfigurationHelperTest.groovy +++ b/test/groovy/com/sap/piper/WhiteSourceConfigurationHelperTest.groovy @@ -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\")")) diff --git a/vars/whitesourceExecuteScan.groovy b/vars/whitesourceExecuteScan.groovy index 4429cf704..632d9706f 100644 --- a/vars/whitesourceExecuteScan.groovy +++ b/vars/whitesourceExecuteScan.groovy @@ -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')