-
Notifications
You must be signed in to change notification settings - Fork 2
/
JenkinsFile
85 lines (77 loc) · 2.63 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
pipeline {
agent { label 'Apathy-node'}
options {
buildDiscarder(
logRotator(
//number of build logs to keep
numToKeepStr:'15',
)
)
}
tools {nodejs "NodeJS 18.17.0"}
stages {
stage('ShutdownService'){
steps {
script {
def exists = fileExists '/lib/systemd/system/cardinal.service'
if (exists) {
sh "sudo systemctl stop cardinal.service"
} else {
println "service doesn't exist"
}
}
}
}
stage('Checkout'){
steps {
echo 'Checking out source code...'
script {
checkout scm
}
}
}
// stage('Install NVM') {
// steps {
// sh 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash'
// sh 'export NVM_DIR="$HOME/.nvm"'
// sh '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm'
// }
// }
stage('Build'){
steps{
echo "Using Node.js version ${NODEJS_HOME}"
echo "Installing Build Dependencies."
sh '''
source $HOME/.nvm/nvm.sh && nvm install 18.17.0
source $HOME/.nvm/nvm.sh && nvm use 18.17.0
sudo chown -R cardinal.cardinal /home/cardinal/.nvm
sudo mkdir -p /opt/cardinal
sudo rsync -av --delete --exclude='data/Cardinal.db' ${WORKSPACE}/* /opt/cardinal/
cd /opt/cardinal
npm --version
npm cache clean --force
sudo rm -rf /opt/cardinal/node_modules
npm install
sudo chown -R cardinal.cardinal /opt/cardinal
sudo chmod -R 775 /opt/cardinal
'''
}
}
stage('UpdateAndStartService'){
steps{
echo "Updating Linux Service"
sh '''
sudo cp /opt/cardinal/cardinal.service /lib/systemd/system/cardinal.service
sudo systemctl daemon-reload
sudo systemctl enable cardinal.service
sudo systemctl start cardinal.service
'''
}
}
/*
Need to test this to see what shows up on the Minion.
Likely add a Move to a new directory
Add a Updated/Execute Service
*/
}
}