mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-30 05:59:39 +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 getGoGAV(file = './glide.yaml') {
|
||||||
def f = new File(file)
|
def path = file.substring(0, file.lastIndexOf('/') + 1)
|
||||||
def path = f.getCanonicalFile().getParentFile()
|
|
||||||
def result = [:]
|
def result = [:]
|
||||||
|
|
||||||
result['group'] = ''
|
result['group'] = ''
|
||||||
result['packaging'] = ''
|
result['packaging'] = ''
|
||||||
result['artifact'] = path.getName()
|
result['artifact'] = path?.replaceAll(/\./, '')?.replaceAll('/', '')
|
||||||
file = new File(path, 'version.txt').getAbsolutePath()
|
file = path + 'version.txt'
|
||||||
result['version'] = getVersionFromFile(file)
|
result['version'] = getVersionFromFile(file)
|
||||||
|
|
||||||
if (!result['version']) {
|
if (!result['version']) {
|
||||||
file = new File(path, 'VERSION').getAbsolutePath()
|
file = path + 'VERSION'
|
||||||
result['version'] = getVersionFromFile(file)
|
result['version'] = getVersionFromFile(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,7 +456,7 @@ class WhitesourceExecuteScanTest extends BasePiperTest {
|
|||||||
void testGo() {
|
void testGo() {
|
||||||
helper.registerAllowedMethod("readFile", [Map.class], {
|
helper.registerAllowedMethod("readFile", [Map.class], {
|
||||||
map ->
|
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)
|
def descriptorFile = new File(path)
|
||||||
if(descriptorFile.exists())
|
if(descriptorFile.exists())
|
||||||
return descriptorFile.text
|
return descriptorFile.text
|
||||||
@ -471,7 +471,7 @@ class WhitesourceExecuteScanTest extends BasePiperTest {
|
|||||||
"productName": "SHC - Piper",
|
"productName": "SHC - Piper",
|
||||||
"checkPolicies": "true",
|
"checkPolicies": "true",
|
||||||
"projectName": "python-test",
|
"projectName": "python-test",
|
||||||
"projectVersion": "1.0.0"
|
"projectVersion": "2.0.0"
|
||||||
])
|
])
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
@ -515,7 +515,7 @@ class WhitesourceExecuteScanTest extends BasePiperTest {
|
|||||||
|
|
||||||
helper.registerAllowedMethod("readFile", [Map.class], {
|
helper.registerAllowedMethod("readFile", [Map.class], {
|
||||||
map ->
|
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)
|
def descriptorFile = new File(path)
|
||||||
if(descriptorFile.exists())
|
if(descriptorFile.exists())
|
||||||
return descriptorFile.text
|
return descriptorFile.text
|
||||||
|
@ -417,7 +417,7 @@ private resolveProjectIdentifiers(script, descriptorUtils, config) {
|
|||||||
config.whitesource.projectName = "${gav.group?:''}${gav.group?'.':''}${gav.artifact}"
|
config.whitesource.projectName = "${gav.group?:''}${gav.group?'.':''}${gav.artifact}"
|
||||||
|
|
||||||
def versionFragments = gav.version?.tokenize('.')
|
def versionFragments = gav.version?.tokenize('.')
|
||||||
def version = versionFragments ? versionFragments.head() : null
|
def version = versionFragments.size() > 0 ? versionFragments.head() : null
|
||||||
if(version && !config.whitesource.productVersion)
|
if(version && !config.whitesource.productVersion)
|
||||||
config.whitesource.productVersion = version
|
config.whitesource.productVersion = version
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user