def remote = [:] remote.name = 'remote' remote.host = env.DEPLOY_HOST remote.user = env.DEPLOY_USER remote.identityFile = '/var/lib/jenkins/.ssh/id_rsa' remote.knownHosts = '/var/lib/jenkins/.ssh/known_hosts' remote.allowAnyHosts = true remote.retryCount = 3 remote.retryWaitSec = 3 logLevel = 'FINER' pipeline { agent none environment { HOME='.' } stages { stage('Build') { agent { docker { image 'node:10-alpine' args '--network "host"' } } steps { sh 'cd music_graph/ && npm install && npm run build' sh 'mv music_graph/dist webroot' stash includes: 'webroot/', name: 'webdist' } } stage('Deploy') { agent none steps { node('master') { unstash 'webdist' sshCommand remote: remote, command: "cd music-graph && rm -rf webroot/* deploy.sh" sshPut remote: remote, from: 'webroot/', into: 'music-graph' sshPut remote: remote, from: 'jenkins/deploy.sh', into: 'music-graph/' sshCommand remote: remote, command: 'chmod +x music-graph/deploy.sh && ./music-graph/deploy.sh' } } } } }