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
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
def versionFound = packages.find {
|
|
|
|
return it['version'] =~ expectedVersion
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return packages
|
|
|
|
}
|