Мне нужно решение для следующего: поиск переменной значения BRANCHVERSION
в ver_list
, сравнение их и использование соответствующего.
BRANCHVERSION
имеет такой формат "6.200.01"
ver_list
выглядит следующим образом
[Pipeline] echo
[6.000.02, 6.000.10, 6.000.12, 6.000.15, 6.000.20, 6.000.25, 6.000.30, 6.100.00, 6.100.01, 6.100.10, 6.100.20, 6.100.25, 6.100.30, 6.200.00, 6.300.00]
, если BRANCHVERSION
не равно каким-либо значениям в ver_list
, то следующее ближайшее значение из списка, упорядоченное по убыванию, должнобыть подобрано (если BRANCHVERSION
= 6.200.01, то должно быть взято 6.200.00), если BRANCHVERSION
равно любым значениям в ver_list
, то это значение будет взято.
Мой конвейер описан ниже:
if (ENVIRONMENT == "") {
error("You should choose at least one environment")
}
node {
deleteDir()
checkout([$class: 'SubversionSCM', locations: [[credentialsId: 'XXXXXXX',local: './env_prop_files', remote:'http://FQDN/repos/src/cm/env_prop_files']]])
checkout([$class: 'SubversionSCM', locations: [[credentialsId: 'XXXXXXX',local: './SoapUITestSuites', remote:'http://FQDN/repos/src/tools/SoapUI/branches/']]])
def FILES_LIST = sh (script: "ls './SoapUITestSuites'", returnStdout:true).trim()
def GS_LIST = sh (script: "ls 'path_to_file'", returnStdout: true).trim()
echo "GS_Version : ${GS_LIST}"
echo "FILES_LIST : ${FILES_LIST}"
//PARSING TestSuite Version
def ver_list = []
for(String ele : FILES_LIST.split("\\r?\\n")){
ver = ele.split("_")
println ">>>${ver[1]}<<<"
ver_list.add(ver[1])
}
println(ver_list)
def VERSION = ver_list
//PARSING GS Version
def gs_list = []
for(String elegs : GS_LIST.split("\\r?\\n")){
println ">>>${elegs}<<<"
gs_list.add(elegs)
}
println(gs_list)
properties = readProperties file:"./env_prop_files/${ENVIRONMENT}.properties"
BRANCHVERSION = properties.SVN_LOCATION_VERSION
}
ВЫХОД
No changes for http://FQDN/repos/src/tools/SoapUI/branches since the previous
build
[Pipeline] sh
[ClientRunSoapUITest] Running shell script
+ ls ./SoapUITestSuites
[Pipeline] sh
[ClientRunSoapUITest] Running shell script
+ ls /pkg/flexprod/oracle/flexprodfiles/archive/goldstand
[Pipeline] echo
GS_Version : 5.900.00
6.000.00
6.000.01
6.000.02
6.000.20
6.000.30
6.100.00
6.100.01
6.200.00
[Pipeline] echo
FILES_LIST : rel_6.000.02
rel_6.000.10
rel_6.000.12
rel_6.000.15
rel_6.000.20
rel_6.000.25
rel_6.000.30
rel_6.100.00
rel_6.100.01
rel_6.100.10
rel_6.100.20
rel_6.100.25
rel_6.100.30
rel_6.200.00
rel_6.200.01
rel_6.300.00
[Pipeline] echo
>>>6.000.02<<<
[Pipeline] echo
>>>6.000.10<<<
[Pipeline] echo
>>>6.000.12<<<
[Pipeline] echo
>>>6.000.15<<<
[Pipeline] echo
>>>6.000.20<<<
[Pipeline] echo
>>>6.000.25<<<
[Pipeline] echo
>>>6.000.30<<<
[Pipeline] echo
>>>6.100.00<<<
[Pipeline] echo
>>>6.100.01<<<
[Pipeline] echo
>>>6.100.10<<<
[Pipeline] echo
>>>6.100.20<<<
[Pipeline] echo
>>>6.100.25<<<
[Pipeline] echo
>>>6.100.30<<<
[Pipeline] echo
>>>6.200.00<<<
[Pipeline] echo
>>>6.200.01<<<
[Pipeline] echo
>>>6.300.00<<<
[Pipeline] echo
[6.000.02, 6.000.10, 6.000.12, 6.000.15, 6.000.20, 6.000.25, 6.000.30, 6.100.00, 6.100.01, 6.100.10, 6.100.20, 6.100.25, 6.100.30, 6.200.00, 6.200.01, 6.300.00]
[Pipeline] echo
>>>5.900.00<<<
[Pipeline] echo
>>>6.000.00<<<
[Pipeline] echo
>>>6.000.01<<<
[Pipeline] echo
>>>6.000.02<<<
[Pipeline] echo
>>>6.000.20<<<
[Pipeline] echo
>>>6.000.30<<<
[Pipeline] echo
>>>6.100.00<<<
[Pipeline] echo
>>>6.100.01<<<
[Pipeline] echo
>>>6.200.00<<<
[Pipeline] echo
[5.900.00, 6.000.00, 6.000.01, 6.000.02, 6.000.20, 6.000.30, 6.100.00, 6.100.01, 6.200.00]
[Pipeline] readProperties
[Pipeline] }
[Pipeline] // node
[Pipeline] echo
"6.200.01"
[Pipeline] lock