-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.staging
65 lines (55 loc) · 1.96 KB
/
Jenkinsfile.staging
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
pipeline {
agent any
tools {
nodejs 'NodeJS 6.9.5'
}
stages {
stage('Checkout') {
steps {
slackSend channel: '#ops-builds',
color: '#D5D8DC',
message: "The pipeline ${currentBuild.fullDisplayName} started."
echo 'Getting source code...'
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '208a185a-927b-4923-9599-c8dfcb0e8611', url: 'https://github.com/MyThreadLab/threadlab-frontend']]])
script {
def SERVER_DIR = "${env.WORKSPACE}/server"
def OUTPUT_DIR = "/var/www/html/threadlab-frontend/"
echo 'Copying server files...'
sh "cp -r ${SERVER_DIR} ${OUTPUT_DIR}"
}
}
}
stage('Build: Dependencies') {
steps {
echo 'Building dependencies...'
withEnv(["NPM_CONFIG_LOGLEVEL=warn"]) {
sh 'npm cache clean --force'
sh 'npm i'
}
}
}
stage('Build: App') {
steps {
echo 'Building web app...'
sh 'npm run build:staging'
}
}
stage('Server: Restart') {
steps {
sh 'JENKINS_NODE_COOKIE=dontKillMe ./scripts/restart.sh'
}
}
}
post {
success {
slackSend channel: '#ops-builds',
color: 'good',
message: "The pipeline ${currentBuild.fullDisplayName} completed successfully."
}
failure {
slackSend channel: '#ops-builds',
color: 'danger',
message: "The pipeline ${currentBuild.fullDisplayName} failed."
}
}
}