Jenkins/vars/vulcain.groovy

20 lines
1007 B
Groovy
Raw Normal View History

def publish(
2019-02-20 15:30:20 +01:00
List packages = [],
String packagesEnv = 'dev',
String packagesBranch = '',
String sshCredentialsId = 'vulcain-packages-ssh-keypair',
String vulcainHost = 'vulcain.cadoles.com'
) {
if (!packagesBranch) {
packagesBranch = env.BRANCH_NAME
}
withCredentials([
sshUserPrivateKey(credentialsId: sshCredentialsId, keyFileVariable: 'VULCAIN_SSH_KEY', usernameVariable: 'VULCAIN_SSH_USER')
]) {
echo "Publishing packages to '${packagesEnv}/${packagesBranch}'"
2019-02-20 15:30:20 +01:00
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}'"
packages.each {
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}/'"
2019-02-20 15:30:20 +01:00
}
}
}