-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathJenkinsfile
93 lines (84 loc) · 2.56 KB
/
Jenkinsfile
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
pipeline {
agent any
environment {
NODE_VERSION = '23.2.0'
NVM_DIR = '/var/jenkins_home/.nvm'
}
stages {
stage('Setup NVM') {
steps {
sh '''
# Install NVM if not present
if [ ! -d "$NVM_DIR" ]; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
export NVM_DIR="$NVM_DIR"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
fi
'''
}
}
stage('Setup Node') {
steps {
sh '''
export NVM_DIR="$NVM_DIR"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm install ${NODE_VERSION}
nvm use ${NODE_VERSION}
'''
}
}
stage('Install Dependencies') {
steps {
sh '''
export NVM_DIR="$NVM_DIR"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm use ${NODE_VERSION}
npm install
'''
}
}
stage('Run Tests') {
steps {
sh '''
export NVM_DIR="$NVM_DIR"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm use ${NODE_VERSION}
npm test
'''
}
}
stage('Download Assets') {
steps {
sh '''
export NVM_DIR="$NVM_DIR"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm use ${NODE_VERSION}
npm run download-videos
'''
}
}
stage('Build Sites') {
steps {
sh '''
export NVM_DIR="$NVM_DIR"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm use ${NODE_VERSION}
npm run build
'''
}
}
stage('Deploy') {
steps {
sh '''
rsync -av output/justinholmes.com.public.dist/ /var/www/justinholmes.com/
rsync -av output/cryptograss.live.public.dist/ /var/www/cryptograss.live/
'''
}
}
}
post {
always {
cleanWs()
}
}
}