Compare commits
10 Commits
redesign-t
...
hooks
Author | SHA1 | Date | |
---|---|---|---|
97aa9b61dd | |||
ec523ddfb4 | |||
78c8a9e74e | |||
4cb30fa836 | |||
3b6e1e0f72 | |||
5ef2c5bf95 | |||
c90b26695a | |||
218868991f | |||
62558c6327 | |||
ff1b1f148d |
21
README.md
21
README.md
@ -1,18 +1,31 @@
|
|||||||
# Jenkins
|
# Jenkins
|
||||||
|
|
||||||
Librairie utilitaire pour la création de pipeline Jenkins dans l'environnement Cadoles.
|
Utilitaires pour la création de pipeline Jenkins dans l'environnement Cadoles.
|
||||||
|
|
||||||
## Méthodes exposées
|
## Pipelines
|
||||||
|
|
||||||
### Création de paquets
|
- [Pipeline d'empaquetage Debian](./pipelines/debian-packaging.jenkinsfile)
|
||||||
|
|
||||||
|
## Librairie
|
||||||
|
|
||||||
|
### Méthodes exposées
|
||||||
|
|
||||||
|
#### Création de paquets
|
||||||
|
|
||||||
- [`tamarin.buildPackage()`](./vars/tamarin.groovy#L48)
|
- [`tamarin.buildPackage()`](./vars/tamarin.groovy#L48)
|
||||||
- [`tamarin.buildPackageWithCPKG()`](./vars/tamarin.groovy#L1)
|
- [`tamarin.buildPackageWithCPKG()`](./vars/tamarin.groovy#L1)
|
||||||
|
|
||||||
### Publication de paquets
|
#### Publication de paquets
|
||||||
|
|
||||||
- [`vulcain.publish()`](./vars/vulcain.groovy#L1)
|
- [`vulcain.publish()`](./vars/vulcain.groovy#L1)
|
||||||
|
|
||||||
|
#### Pilotage d'OpenNebula
|
||||||
|
|
||||||
|
- [`nebula.initWithCredentials()`](./vars/nebula.groovy#L125)
|
||||||
|
- [`nebula.runInNewVM() { client -> ... }`](./vars/nebula.groovy#L135)
|
||||||
|
- [`client.findVMTemplate()`](./vars/nebula.groovy#L65)
|
||||||
|
- [`client.withNewVM()`](./vars/nebula.groovy#L79)
|
||||||
|
|
||||||
## Licence
|
## Licence
|
||||||
|
|
||||||
GPL-3.0
|
GPL-3.0
|
||||||
|
163
pipelines/debian-packaging.jenkinsfile
Normal file
163
pipelines/debian-packaging.jenkinsfile
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
@Library("cadoles") _
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
|
||||||
|
agent {
|
||||||
|
label 'common'
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
projectDir = "${env.project_name}_${env.BUILD_ID}"
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
|
||||||
|
stage("Clone repository") {
|
||||||
|
steps {
|
||||||
|
checkout scm:
|
||||||
|
[
|
||||||
|
$class: 'GitSCM',
|
||||||
|
userRemoteConfigs: [[url: env.repository_url, credentialsId: 'forge-jenkins']],
|
||||||
|
branches: [[name: env.ref]],
|
||||||
|
extensions: [
|
||||||
|
[$class: 'RelativeTargetDirectory', relativeTargetDir: env.projectDir ],
|
||||||
|
[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: ''],
|
||||||
|
[$class: 'WipeWorkspace' ]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
changelog: false,
|
||||||
|
poll: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("Ensure packaging branch") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
dir(env.projectDir) {
|
||||||
|
sh 'git checkout "${packageBranch}"'
|
||||||
|
def commitOrRef = env.commit ? env.commit : env.ref
|
||||||
|
def branchesWithCommitOrRef = sh(script: "git branch --contains '${commitOrRef}'", returnStdout: true).split(' ')
|
||||||
|
if (branchesWithCommitOrRef.findAll{env.packageBranch.contains(it)}.any{true}) {
|
||||||
|
currentBuild.result = 'ABORTED'
|
||||||
|
error("La référence `${env.ref}` ne fait pas partie de la branche `${env.packageBranch}` !")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("Checkout ref") {
|
||||||
|
steps {
|
||||||
|
dir(env.projectDir) {
|
||||||
|
sh """
|
||||||
|
git checkout ${env.ref}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("Build package") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
dir(env.projectDir) {
|
||||||
|
|
||||||
|
// On construit les paquets à partir des informations
|
||||||
|
// de contexte provenant de CPKG et du webhook
|
||||||
|
def result = tamarin.buildPackageWithCPKG(
|
||||||
|
env.packageProfile ? env.packageProfile : "debian",
|
||||||
|
env.packageArch ? env.packageArch : "",
|
||||||
|
env.packageBranch ? env.packageBranch : "",
|
||||||
|
env.baseImage ? env.baseImage : ""
|
||||||
|
)
|
||||||
|
|
||||||
|
// On publie chacun des paquets construits
|
||||||
|
result.each { r ->
|
||||||
|
vulcain.publish(
|
||||||
|
r.packages,
|
||||||
|
r.env,
|
||||||
|
env.packageBranch
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// On liste l'ensemble des paquets construits
|
||||||
|
def publishedPackages = result.collect { r ->
|
||||||
|
return r.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 (
|
||||||
|
avatar: 'https://jenkins.cadol.es/static/b5f67753/images/headshot.png',
|
||||||
|
message: """
|
||||||
|
Les paquets suivants ont été publiés pour le projet ${env.project_name}:
|
||||||
|
|
||||||
|
${publishedPackages.join('\n')}
|
||||||
|
|
||||||
|
[Visualiser le job](${env.RUN_DISPLAY_URL})
|
||||||
|
|
||||||
|
@${env.sender_login}
|
||||||
|
""".stripIndent(),
|
||||||
|
rawMessage: true
|
||||||
|
)
|
||||||
|
|
||||||
|
if (env.testPackageInstall == 'no') {
|
||||||
|
println "Test d'intallation des paquets désactivé."
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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]
|
||||||
|
|
||||||
|
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]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
sh "rm -rf '${env.projectDir}'"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cette fonction fait un simple "mapping"
|
||||||
|
// entre les distributions cibles des paquets et
|
||||||
|
// les templates de VM disponibles sur l'OpenNebula
|
||||||
|
def findMatchingVMTemplate(String distrib) {
|
||||||
|
def vmTemplatesMap = [
|
||||||
|
'eole-2.7.0': 'eolebase-2.7.0-cadoles',
|
||||||
|
'eole-2.6.2': 'eolebase-2.6.2-cadoles'
|
||||||
|
]
|
||||||
|
return vmTemplatesMap.get(distrib, null)
|
||||||
|
}
|
87
pipelines/debian-test-package.jenkinsfile
Normal file
87
pipelines/debian-test-package.jenkinsfile
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
@Library("cadoles") _
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
|
||||||
|
agent {
|
||||||
|
label 'common'
|
||||||
|
}
|
||||||
|
|
||||||
|
parameters {
|
||||||
|
string(
|
||||||
|
name: 'packageName',
|
||||||
|
description: 'Nom du paquet à installer'
|
||||||
|
)
|
||||||
|
string(
|
||||||
|
name: 'packageVersion',
|
||||||
|
defaultValue: '',
|
||||||
|
description: 'Version du paquet à installer'
|
||||||
|
)
|
||||||
|
string(
|
||||||
|
name: 'packageRepository',
|
||||||
|
description: 'Dépôt de paquets à utiliser sur Vulcain'
|
||||||
|
)
|
||||||
|
string(
|
||||||
|
name: 'vmTemplate',
|
||||||
|
description: 'Template OpenNebula de la VM à utiliser pour le test d\'installation'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
|
||||||
|
stage("Check parameters") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
if (!params.packageName?.trim()) {
|
||||||
|
error("Le nom du paquet n'est pas défini !")
|
||||||
|
}
|
||||||
|
if (!params.vmTemplate?.trim()) {
|
||||||
|
error("Le template de VM n'est pas défini !")
|
||||||
|
}
|
||||||
|
if (!params.packageRepository?.trim()) {
|
||||||
|
error("Le dépôt de paquets n'est pas défini !")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("Test package installation") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
nebula.runScriptInNewVM([
|
||||||
|
vmTemplate: params.vmTemplate,
|
||||||
|
script: """
|
||||||
|
set -xeo pipefail
|
||||||
|
wget -qO - https://vulcain.cadoles.com/cadoles.gpg | apt-key add -
|
||||||
|
echo 'deb https://vulcain.cadoles.com ${params.packageRepository} main' > /etc/apt/sources.list.d/${params.packageRepository}.list
|
||||||
|
apt-get update -y
|
||||||
|
apt-get install -y ${params.packageName}${ params.packageVersion?.trim() ? '=' + params.packageVersion?.trim() : ''}
|
||||||
|
"""
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
failure {
|
||||||
|
wrap([$class: 'BuildUser']) {
|
||||||
|
rocketSend (
|
||||||
|
avatar: 'https://jenkins.cadol.es/static/b5f67753/images/headshot.png',
|
||||||
|
message: """
|
||||||
|
Le test d'installation du paquet `${params.packageName}` a échoué:
|
||||||
|
|
||||||
|
- Version `${params.packageVersion}`
|
||||||
|
- Dépôt `${params.packageRepository}`
|
||||||
|
- Template de la VM `${params.vmTemplate}`
|
||||||
|
|
||||||
|
[Voir le job](${env.RUN_DISPLAY_URL})
|
||||||
|
|
||||||
|
@${env.BUILD_USER_ID ? env.BUILD_USER_ID : 'here'}
|
||||||
|
""".stripIndent(),
|
||||||
|
rawMessage: true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
15
vars/hook.groovy
Normal file
15
vars/hook.groovy
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
def call(String name) {
|
||||||
|
def rootDir = pwd()
|
||||||
|
def filepath = "${rootDir}/.jenkins/${name}.groovy"
|
||||||
|
def exists = fileExists(filepath)
|
||||||
|
if (!exists) {
|
||||||
|
println("No hook '${filepath}' script. Skipping.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
def hook = load(filepath)
|
||||||
|
if(hook.metaClass.respondsTo(hook, 'exec')) {
|
||||||
|
hook.exec()
|
||||||
|
} else {
|
||||||
|
error("Hook script '${filepath}' exists but does not expose an exec() function.")
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import groovy.util.XmlSlurper
|
|||||||
import groovy.util.slurpersupport.GPathResult
|
import groovy.util.slurpersupport.GPathResult
|
||||||
import groovy.util.slurpersupport.NodeChild
|
import groovy.util.slurpersupport.NodeChild
|
||||||
import groovy.xml.XmlUtil
|
import groovy.xml.XmlUtil
|
||||||
|
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
|
||||||
|
|
||||||
class Client {
|
class Client {
|
||||||
|
|
||||||
@ -132,7 +133,15 @@ def initWithCredentials(String urlCredentialsId, String userCredentialsId, Closu
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def runInNewVM(Map args) {
|
def runScriptInNewVM(Map args) {
|
||||||
|
def script = args.get("script", "")
|
||||||
|
runInNewVM(args) { shell ->
|
||||||
|
shell(script)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def runInNewVM(Map args, Closure body) {
|
||||||
|
|
||||||
def urlCredentialsId = args.get('urlCredentialsId', 'opennebula-dev-url')
|
def urlCredentialsId = args.get('urlCredentialsId', 'opennebula-dev-url')
|
||||||
def userCredentialsId = args.get('userCredentialsId', 'kipp-credentials')
|
def userCredentialsId = args.get('userCredentialsId', 'kipp-credentials')
|
||||||
@ -140,7 +149,7 @@ def runInNewVM(Map args) {
|
|||||||
def vmTemplate = args.get('vmTemplate', '')
|
def vmTemplate = args.get('vmTemplate', '')
|
||||||
def terminateOnExit = args.get('terminateOnExit', true)
|
def terminateOnExit = args.get('terminateOnExit', true)
|
||||||
def shell = args.get("shell", "/bin/sh")
|
def shell = args.get("shell", "/bin/sh")
|
||||||
def script = args.get('script', '')
|
def connectionTimeout = args.get('connectionTimeout', 10)
|
||||||
|
|
||||||
// On récupère les identifiants de connexion SSH pour la VM
|
// On récupère les identifiants de connexion SSH pour la VM
|
||||||
withCredentials([
|
withCredentials([
|
||||||
@ -149,33 +158,38 @@ def runInNewVM(Map args) {
|
|||||||
initWithCredentials(urlCredentialsId, userCredentialsId) { client ->
|
initWithCredentials(urlCredentialsId, userCredentialsId) { client ->
|
||||||
client.withNewVM(vmTemplate, terminateOnExit) { host ->
|
client.withNewVM(vmTemplate, terminateOnExit) { host ->
|
||||||
|
|
||||||
def sshArgs = "-i ${VM_SSH_KEY} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
def sshArgs = "-i '${VM_SSH_KEY}' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||||
|
|
||||||
// On attend que la connexion SSH soit disponible
|
// On attend que la connexion SSH soit disponible
|
||||||
println "En attente de l'accès SSH..."
|
println "En attente de l'accès SSH sur la machine ${host}..."
|
||||||
waitUntil {
|
timeout(connectionTimeout) {
|
||||||
try {
|
while(true) {
|
||||||
sh "ssh -q ${sshArgs} -o ConnectTimeout=1 root@${host} exit"
|
def status = sh script: "nc -zv ${host} 22", returnStatus: true
|
||||||
return true
|
if (status == 0) {
|
||||||
} catch (e) {
|
break;
|
||||||
return false
|
}
|
||||||
|
sleep(5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// On créait un script temporaire à exécuter sur la machine distante
|
def remoteShell = { script ->
|
||||||
def now = System.currentTimeMillis()
|
// On créait un script temporaire à exécuter sur la machine distante
|
||||||
def tempScriptFile = "script_${env.BUILD_ID}_${now}.sh"
|
def now = System.currentTimeMillis()
|
||||||
writeFile(file: tempScriptFile, text: """
|
def tempScriptFile = "script_${env.BUILD_ID}_${now}.sh"
|
||||||
#!${shell}
|
writeFile(file: tempScriptFile, text: """
|
||||||
${script.stripIndent()}
|
#!${shell}
|
||||||
""")
|
${script.stripIndent()}
|
||||||
|
""")
|
||||||
|
// On transfère le script sur la machine distante et on l'exécute
|
||||||
|
sh """
|
||||||
|
scp ${sshArgs} '${tempScriptFile}' 'root@${host}:/tmp/${tempScriptFile}'
|
||||||
|
ssh ${sshArgs} root@${host} 'chmod +x /tmp/${tempScriptFile}; /tmp/${tempScriptFile}'
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
// On transfère le script sur la machine distante et on l'exécute
|
body(remoteShell)
|
||||||
sh """
|
|
||||||
scp ${sshArgs} '${tempScriptFile}' 'root@${host}:/tmp/${tempScriptFile}'
|
|
||||||
ssh ${sshArgs} root@${host} 'chmod +x /tmp/${tempScriptFile}; /tmp/${tempScriptFile}'
|
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,10 +4,11 @@ def buildPackageWithCPKG(
|
|||||||
String packageBranch = "",
|
String packageBranch = "",
|
||||||
String baseImage = "",
|
String baseImage = "",
|
||||||
String destDir = "./packages",
|
String destDir = "./packages",
|
||||||
Boolean forceRebuild = false,
|
Boolean forceRebuild = false
|
||||||
Boolean publishPackages = true
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
def builds = []
|
||||||
|
|
||||||
// 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(' ')
|
||||||
if (commitTags.length == 0) {
|
if (commitTags.length == 0) {
|
||||||
@ -30,20 +31,23 @@ def buildPackageWithCPKG(
|
|||||||
""".stripIndent()
|
""".stripIndent()
|
||||||
writeFile file: '.tamarinrc', text: tamarinrc
|
writeFile file: '.tamarinrc', text: tamarinrc
|
||||||
|
|
||||||
|
sh "rm -rf ${destDir}/*"
|
||||||
|
|
||||||
stage("Build ${packageEnv} package (version ${packageVersion}) for ${packageDistrib}") {
|
stage("Build ${packageEnv} package (version ${packageVersion}) for ${packageDistrib}") {
|
||||||
|
def result = [:]
|
||||||
sh "rm -rf ${destDir}/*"
|
result.put('tag', tag)
|
||||||
buildPackage(packageProfile, packageArch, baseImage, destDir, forceRebuild)
|
result.put('env', packageEnv)
|
||||||
|
result.put('version', packageVersion)
|
||||||
if (publishPackages) {
|
result.put('distrib', packageDistrib)
|
||||||
stage("Publish ${packageEnv} packages (version ${packageVersion}) on Vulcain") {
|
def packages = buildPackage(packageProfile, packageArch, baseImage, destDir, forceRebuild)
|
||||||
vulcain.publish(destDir, packageEnv, packageBranch)
|
result.put('packages', packages)
|
||||||
}
|
builds << result
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return builds
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def buildPackage(
|
def buildPackage(
|
||||||
@ -54,7 +58,8 @@ def buildPackage(
|
|||||||
Boolean forceRebuild = false
|
Boolean forceRebuild = false
|
||||||
) {
|
) {
|
||||||
|
|
||||||
def tamarinImage
|
def tamarinImage
|
||||||
|
def packages = []
|
||||||
|
|
||||||
stage("Create Tamarin environment") {
|
stage("Create Tamarin environment") {
|
||||||
tamarinImage = buildDockerImage()
|
tamarinImage = buildDockerImage()
|
||||||
@ -73,7 +78,14 @@ def buildPackage(
|
|||||||
tamarinImage.inside(dockerArgs) {
|
tamarinImage.inside(dockerArgs) {
|
||||||
sh 'run-tamarin'
|
sh 'run-tamarin'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packages = sh(script: "find '${destDir}' -name '*.deb' -type f", returnStdout: true)
|
||||||
|
.split('\n')
|
||||||
|
.collect { return it.trim() }
|
||||||
|
.findAll { it != '' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return packages
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
def publish(
|
def publish(
|
||||||
String packagesDir = './packages',
|
List packages = [],
|
||||||
String packagesEnv = 'dev',
|
String packagesEnv = 'dev',
|
||||||
String packagesBranch = '',
|
String packagesBranch = '',
|
||||||
String sshCredentialsId = 'vulcain-packages-ssh-keypair',
|
String sshCredentialsId = 'vulcain-packages-ssh-keypair',
|
||||||
@ -8,14 +8,13 @@ def publish(
|
|||||||
if (!packagesBranch) {
|
if (!packagesBranch) {
|
||||||
packagesBranch = env.BRANCH_NAME
|
packagesBranch = env.BRANCH_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
withCredentials([
|
withCredentials([
|
||||||
sshUserPrivateKey(credentialsId: sshCredentialsId, keyFileVariable: 'VULCAIN_SSH_KEY', usernameVariable: 'VULCAIN_SSH_USER')
|
sshUserPrivateKey(credentialsId: sshCredentialsId, keyFileVariable: 'VULCAIN_SSH_KEY', usernameVariable: 'VULCAIN_SSH_USER')
|
||||||
]) {
|
]) {
|
||||||
echo "Publishing packages to '${packagesEnv}/${packagesBranch}'"
|
echo "Publishing packages to '${packagesEnv}/${packagesBranch}'"
|
||||||
sh """
|
sh "ssh -i '${VULCAIN_SSH_KEY}' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '${VULCAIN_SSH_USER}@${vulcainHost}' mkdir -p '/home/${VULCAIN_SSH_USER}/packages/${packagesEnv}/${packagesBranch}'"
|
||||||
ssh -i '${VULCAIN_SSH_KEY}' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '${VULCAIN_SSH_USER}@${vulcainHost}' mkdir -p '/home/${VULCAIN_SSH_USER}/packages/${packagesEnv}/${packagesBranch}'
|
packages.each {
|
||||||
scp -i '${VULCAIN_SSH_KEY}' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r ${packagesDir}/*.deb '${VULCAIN_SSH_USER}@${vulcainHost}:/home/${VULCAIN_SSH_USER}/packages/${packagesEnv}/${packagesBranch}/'
|
sh "scp -C -i '${VULCAIN_SSH_KEY}' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '${it}' '${VULCAIN_SSH_USER}@${vulcainHost}:/home/${VULCAIN_SSH_USER}/packages/${packagesEnv}/${packagesBranch}/'"
|
||||||
"""
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user