Ajustements
Cadoles/Jenkins/pipeline/head There was a failure building this commit Details

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

26
Jenkinsfile vendored
View File

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

View File

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