def call(String buildDir, String artifactsDir, String remoteHost, String remotePath) { dir(buildDir) { sh """ dpkg-buildpackage -us -uc mkdir -p ${artifactsDir} && mv ../*.deb ../*.changes ../*.buildinfo ${artifactsDir}/ ssh aptly@${remoteHost} "rm -rf ${remotePath}/* && mkdir -p ${remotePath}" scp -r ${artifactsDir}/* aptly@${remoteHost}:${remotePath}/ """ } }