Ajustements
Some checks failed
Cadoles/Jenkins/pipeline/head There was a failure building this commit

This commit is contained in:
Benjamin Bohard 2022-02-08 08:33:09 +01:00
parent 471b11740e
commit 4ce857ef7c
2 changed files with 34 additions and 40 deletions

66
Jenkinsfile vendored
View File

@ -103,9 +103,9 @@ pipeline {
)
// On publie chacun des paquets construits
def credentials = '6aa5444e-16d6-4492-ab72-31d925d13430'
def repositoryHREF = pulp.getRepositoryHREF(credentials, 'dev')
def exportTasks = pulp.exportPackages(credentials, result)
def credentials = '212d6dc7-f9a2-4d27-94d8-de7fc6cae0a1'
def repositoryHREF = pulp.getRepositoryHREF(credentials, result.env)
def exportTasks = pulp.exportPackages(credentials, result.packages)
def pulpPackages = []
exportTasks.each {
def created_resources = pulp.waitForTaskCompletion(credentials, it)
@ -114,17 +114,17 @@ pipeline {
}
}
pulp.addToRepository(credentials, pulpPackages, repositoryHREF)
def publicationHREF = pulp.publishRepository(credentials, repositoryHREF)
def distributionHREF = pulp.distributePublication(credentials, publicationHREF[0], 'cadoles', 'cadoles')
println(pulp.getDistributionURL(credentials, distributionHREF[0]))
if (result.env == 'dev') {
def publicationHREF = pulp.publishRepository(credentials, repositoryHREF)
def distributionHREF = pulp.distributePublication(credentials, publicationHREF[0], 'Cadoles4MSE_dev', 'Cadoles4MSE_dev')
println(pulp.getDistributionURL(credentials, distributionHREF[0]))
}
// On liste l'ensemble des paquets construits
def publishedPackages = result.collect { r ->
return r.packages.collect { p ->
def publishedPackages = result.packages.collect { p ->
def file = new File(p)
return "- Paquet `${file.getName()}`, Dépôt `${r.env}`, Distribution `${r.distrib}`"
}
}.transpose().collectMany { it }
}
// On notifie le canal Rocket.Chat de la publication des paquets
rocketSend (
@ -147,35 +147,31 @@ pipeline {
return
}
// Pour chaque construction de paquets...
result.each { r ->
// On essaye de trouver un template de VM compatible
// avec la distribution cible de la construction
def vmTemplate = findMatchingVMTemplate(r.distrib)
if (vmTemplate == null) {
println "Aucun template de VM n'a été trouvé correspondant à la distribution `${r.distrib}`."
return
}
// On essaye de trouver un template de VM compatible
// avec la distribution cible de la construction
def vmTemplate = findMatchingVMTemplate(result.distrib)
if (vmTemplate == null) {
println "Aucun template de VM n'a été trouvé correspondant à la distribution `${result.distrib}`."
return
}
// Pour chaque paquets construits...
r.packages.each { p ->
def packageFullName = new File(p).getName()
def packageRepository = r.distrib.split('-')[1] + '-' + r.env
def packageNameParts = packageFullName.split('_')
def packageName = packageNameParts[0]
def packageVersion = packageNameParts[1]
// Pour chaque paquets construits...
result.packages.each { p ->
def packageFullName = new File(p).getName()
def packageRepository = result.distrib.split('-')[1] + '-' + r.env
def packageNameParts = packageFullName.split('_')
def packageName = packageNameParts[0]
def packageVersion = packageNameParts[1]
stage("Test package '${packageName}' installation") {
build job: 'Test de paquet Debian', wait: false, parameters: [
[$class: 'StringParameterValue', name: 'packageName', value: packageName],
[$class: 'StringParameterValue', name: 'packageVersion', value: packageVersion],
[$class: 'StringParameterValue', name: 'packageRepository', value: packageRepository],
[$class: 'StringParameterValue', name: 'vmTemplate', value: vmTemplate]
]
}
stage("Test package '${packageName}' installation") {
build job: 'Test de paquet Debian', wait: false, parameters: [
[$class: 'StringParameterValue', name: 'packageName', value: packageName],
[$class: 'StringParameterValue', name: 'packageVersion', value: packageVersion],
[$class: 'StringParameterValue', name: 'packageRepository', value: packageRepository],
[$class: 'StringParameterValue', name: 'vmTemplate', value: vmTemplate]
]
}
}
}
}
}

View File

@ -7,7 +7,7 @@ def buildPackageWithCPKG(
Boolean forceRebuild = false
) {
def builds = []
def result = [:]
// Retrieve commit tags
def commitTags = sh(script: 'git describe --exact-match --abbrev=0', returnStdout: true).split(' ')
@ -34,19 +34,17 @@ def buildPackageWithCPKG(
sh "rm -rf ${destDir}/*"
stage("Build ${packageEnv} package (version ${packageVersion}) for ${packageDistrib}") {
def result = [:]
result.put('tag', tag)
result.put('env', packageEnv)
result.put('version', packageVersion)
result.put('distrib', packageDistrib)
def packages = buildPackage(packageProfile, packageArch, baseImage, destDir, forceRebuild)
result.put('packages', packages)
builds << result
}
}
return builds
return result
}
@ -129,4 +127,4 @@ def buildDockerImage() {
def imageTag = "${safeJobName}-${env.BUILD_ID}"
return docker.build("tamarin:${imageTag}", ".")
}
}
}