mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-18 05:18:24 +02:00
Fix path handling
This commit is contained in:
parent
c71f420995
commit
f928878c5e
@ -89,18 +89,17 @@ def getPipGAV(file = 'setup.py') {
|
||||
}
|
||||
|
||||
def getGoGAV(file = './glide.yaml') {
|
||||
def f = new File(file)
|
||||
def path = f.getCanonicalFile().getParentFile()
|
||||
def path = file.substring(0, file.lastIndexOf('/') + 1)
|
||||
def result = [:]
|
||||
|
||||
result['group'] = ''
|
||||
result['packaging'] = ''
|
||||
result['artifact'] = path.getName()
|
||||
file = new File(path, 'version.txt').getAbsolutePath()
|
||||
result['artifact'] = path?.replaceAll(/\./, '')?.replaceAll('/', '')
|
||||
file = path + 'version.txt'
|
||||
result['version'] = getVersionFromFile(file)
|
||||
|
||||
if (!result['version']) {
|
||||
file = new File(path, 'VERSION').getAbsolutePath()
|
||||
file = path + 'VERSION'
|
||||
result['version'] = getVersionFromFile(file)
|
||||
}
|
||||
|
||||
|
@ -456,7 +456,7 @@ class WhitesourceExecuteScanTest extends BasePiperTest {
|
||||
void testGo() {
|
||||
helper.registerAllowedMethod("readFile", [Map.class], {
|
||||
map ->
|
||||
def path = 'test/resources/DescriptorUtils/go/' + map.file.substring(map.file.lastIndexOf(File.separator) + 1, map.file.length())
|
||||
def path = 'test/resources/DescriptorUtils/go/' + map.file.substring(map.file.lastIndexOf('/') + 1, map.file.length())
|
||||
def descriptorFile = new File(path)
|
||||
if(descriptorFile.exists())
|
||||
return descriptorFile.text
|
||||
@ -471,7 +471,7 @@ class WhitesourceExecuteScanTest extends BasePiperTest {
|
||||
"productName": "SHC - Piper",
|
||||
"checkPolicies": "true",
|
||||
"projectName": "python-test",
|
||||
"projectVersion": "1.0.0"
|
||||
"projectVersion": "2.0.0"
|
||||
])
|
||||
return result
|
||||
})
|
||||
@ -515,7 +515,7 @@ class WhitesourceExecuteScanTest extends BasePiperTest {
|
||||
|
||||
helper.registerAllowedMethod("readFile", [Map.class], {
|
||||
map ->
|
||||
def path = 'test/resources/DescriptorUtils/go/' + map.file.substring(map.file.lastIndexOf(File.separator) + 1, map.file.length())
|
||||
def path = 'test/resources/DescriptorUtils/go/' + map.file.substring(map.file.lastIndexOf('/') + 1, map.file.length())
|
||||
def descriptorFile = new File(path)
|
||||
if(descriptorFile.exists())
|
||||
return descriptorFile.text
|
||||
|
@ -417,7 +417,7 @@ private resolveProjectIdentifiers(script, descriptorUtils, config) {
|
||||
config.whitesource.projectName = "${gav.group?:''}${gav.group?'.':''}${gav.artifact}"
|
||||
|
||||
def versionFragments = gav.version?.tokenize('.')
|
||||
def version = versionFragments ? versionFragments.head() : null
|
||||
def version = versionFragments.size() > 0 ? versionFragments.head() : null
|
||||
if(version && !config.whitesource.productVersion)
|
||||
config.whitesource.productVersion = version
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user