simon987.net/jenkins/Jenkinsfile
2019-04-26 09:41:23 -04:00

48 lines
1.4 KiB
Groovy

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'
}
}
steps {
sh 'cd simon987/ && npm install'
sh 'cd simon987/ && npm audit fix'
sh 'cd simon987/ && npm run build'
sh 'mv simon987/dist webroot'
stash includes: 'webroot/', name: 'webdist'
}
}
stage('Deploy') {
agent none
steps {
node('master') {
unstash 'webdist'
sshCommand remote: remote, command: "cd simon987 && rm -rf webroot/* deploy.sh"
sshPut remote: remote, from: 'webroot/', into: 'simon987'
sshPut remote: remote, from: 'jenkins/deploy.sh', into: 'simon987/'
sshCommand remote: remote, command: 'chmod +x simon987/deploy.sh && ./simon987/deploy.sh'
}
}
}
}
}