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

66
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)
def publicationHREF = pulp.publishRepository(credentials, repositoryHREF) if (result.env == 'dev') {
def distributionHREF = pulp.distributePublication(credentials, publicationHREF[0], 'cadoles', 'cadoles') def publicationHREF = pulp.publishRepository(credentials, repositoryHREF)
println(pulp.getDistributionURL(credentials, distributionHREF[0])) def distributionHREF = pulp.distributePublication(credentials, publicationHREF[0], 'Cadoles4MSE_dev', 'Cadoles4MSE_dev')
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,35 +147,31 @@ pipeline {
return return
} }
// Pour chaque construction de paquets... // On essaye de trouver un template de VM compatible
result.each { r -> // avec la distribution cible de la construction
// On essaye de trouver un template de VM compatible def vmTemplate = findMatchingVMTemplate(result.distrib)
// avec la distribution cible de la construction if (vmTemplate == null) {
def vmTemplate = findMatchingVMTemplate(r.distrib) println "Aucun template de VM n'a été trouvé correspondant à la distribution `${result.distrib}`."
if (vmTemplate == null) { return
println "Aucun template de VM n'a été trouvé correspondant à la distribution `${r.distrib}`." }
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]
stage("Test package '${packageName}' installation") { stage("Test package '${packageName}' installation") {
build job: 'Test de paquet Debian', wait: false, parameters: [ build job: 'Test de paquet Debian', wait: false, parameters: [
[$class: 'StringParameterValue', name: 'packageName', value: packageName], [$class: 'StringParameterValue', name: 'packageName', value: packageName],
[$class: 'StringParameterValue', name: 'packageVersion', value: packageVersion], [$class: 'StringParameterValue', name: 'packageVersion', value: packageVersion],
[$class: 'StringParameterValue', name: 'packageRepository', value: packageRepository], [$class: 'StringParameterValue', name: 'packageRepository', value: packageRepository],
[$class: 'StringParameterValue', name: 'vmTemplate', value: vmTemplate] [$class: 'StringParameterValue', name: 'vmTemplate', value: vmTemplate]
] ]
}
} }
} }
} }
} }
} }

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
} }
@ -129,4 +127,4 @@ def buildDockerImage() {
def imageTag = "${safeJobName}-${env.BUILD_ID}" def imageTag = "${safeJobName}-${env.BUILD_ID}"
return docker.build("tamarin:${imageTag}", ".") return docker.build("tamarin:${imageTag}", ".")
} }
} }