2020-03-19 17:00:36 +01:00
|
|
|
def waitForRepoPackage(String packageName, Map params = [:]) {
|
|
|
|
def expectedVersion = params.expectedVersion ? params.expectedVersion : null
|
|
|
|
def delay = params.delay ? params.delay : 30
|
2021-12-16 09:24:39 +01:00
|
|
|
def waitTimeout = params.timeout ? params.timeout : 2400
|
2022-06-16 17:00:23 +02:00
|
|
|
def asPattern = params.containsKey("asPattern") ? params.asPattern : true
|
2020-03-19 17:00:36 +01:00
|
|
|
|
|
|
|
def message = "Waiting for package '${packageName}'"
|
|
|
|
if (expectedVersion != null) {
|
2020-05-06 10:22:42 +02:00
|
|
|
message += " with version '${expectedVersion}'"
|
2020-03-19 17:00:36 +01:00
|
|
|
}
|
|
|
|
message += '...'
|
|
|
|
println(message)
|
|
|
|
|
|
|
|
timeout(time: waitTimeout, unit: 'SECONDS') {
|
|
|
|
while(true) {
|
|
|
|
println("Retrieving packages list...")
|
|
|
|
def repo = listRepoPackages(params)
|
|
|
|
|
|
|
|
def packages = repo[packageName]
|
|
|
|
if (!packages) {
|
|
|
|
println("Package not found.")
|
|
|
|
sleep(time: delay, unit: 'SECONDS')
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if (expectedVersion == null) {
|
|
|
|
println("Package found !")
|
|
|
|
break
|
|
|
|
}
|
2022-06-16 16:41:29 +02:00
|
|
|
|
2020-03-19 17:00:36 +01:00
|
|
|
def versionFound = packages.find {
|
2022-06-16 17:00:23 +02:00
|
|
|
def matches = asPattern ? it['version'] =~ expectedVersion : it['version'] == expectedVersion
|
2022-06-16 16:41:29 +02:00
|
|
|
println("Comparing expected version '${expectedVersion}' to '${it['version']}': ${matches}")
|
|
|
|
return matches
|
2020-03-19 17:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (versionFound) {
|
|
|
|
println("Expected package version found !")
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
println("Package version not found.")
|
|
|
|
sleep(time: delay, unit: 'SECONDS')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def listRepoPackages(Map params = [:]) {
|
|
|
|
def baseURL = params.baseURL ? params.baseURL : 'https://vulcain.cadoles.com'
|
|
|
|
def distrib = params.distrib ? params.distrib : '2.7.0-dev'
|
|
|
|
def component = params.component ? params.component : 'main'
|
|
|
|
def type = params.type ? params.type : 'binary'
|
|
|
|
def arch = params.arch ? params.arch : 'amd64'
|
|
|
|
|
|
|
|
def response = httpRequest(url: "${baseURL}/dists/${distrib}/${component}/${type}-${arch}/Packages")
|
|
|
|
|
|
|
|
def packages = [:]
|
|
|
|
def lines = response.content.split('\n')
|
|
|
|
|
|
|
|
def currentPackage
|
|
|
|
lines.each {
|
|
|
|
def packageMatch = (it =~ /^Package: (.*)$/)
|
|
|
|
if (packageMatch.find()) {
|
|
|
|
def packageName = packageMatch.group(1)
|
|
|
|
|
|
|
|
if (!packages[packageName]) {
|
|
|
|
packages[packageName] = []
|
|
|
|
}
|
|
|
|
|
|
|
|
currentPackage = [:]
|
|
|
|
currentPackage['name'] = packageName
|
|
|
|
packages[packageName] += currentPackage
|
|
|
|
}
|
|
|
|
|
|
|
|
def versionMatch = (it =~ /^Version: (.*)$/)
|
|
|
|
if (versionMatch.find()) {
|
|
|
|
def version = versionMatch.group(1)
|
|
|
|
currentPackage['version'] = version
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-16 16:41:29 +02:00
|
|
|
println "Found packages:"
|
|
|
|
packages.each{
|
|
|
|
println " - Package: ${it.key}, Version: ${it.value['version']}"
|
|
|
|
}
|
|
|
|
|
2020-03-19 17:00:36 +01:00
|
|
|
return packages
|
|
|
|
}
|