def publish( 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}'" 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}/'" } } }