diff --git a/Jenkinsfile b/Jenkinsfile index 096d524..d79d00f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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] + ] } } - } } } diff --git a/vars/tamarin.groovy b/vars/tamarin.groovy index b2d66c9..a572721 100644 --- a/vars/tamarin.groovy +++ b/vars/tamarin.groovy @@ -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}", ".") } -} \ No newline at end of file +}