-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins.groovy
87 lines (82 loc) · 3.06 KB
/
jenkins.groovy
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
pipeline {
agent any
environment {
BRANCH = "${BRANCH}"
HOST_NAME = "${HOST_NAME}"
PROFILE = "${PROFILE}"
GIT_PATH = 'https://gitlab.filadev.com/erp/fh/cm/fila-cm-web.git'
REMOTE_PATH = '/app/deploy/cm-vue'
}
stages {
stage('Git Clone') {
steps {
cleanWs()
git branch: "$BRANCH", credentialsId: 'fila_ERP_AA', url: "$GIT_PATH"
}
}
stage('Build') {
steps {
nodejs(nodeJSInstallationName: '18') {
sh """
echo BUILD START
cd $WORKSPACE
npm cache verify
npm install
npm run build-$PROFILE
"""
}
}
}
stage('Deploy') {
steps {
sh """
echo DEPLOY START
cd $WORKSPACE
tar -cvf dist.tar dist
"""
sshPublisher(
publishers: [
sshPublisherDesc(
configName: "$HOST_NAME",
transfers: [
sshTransfer(
cleanRemote: false,
excludes: '',
execCommand: """
cd $REMOTE_PATH
rm -rf dist
tar -xvf dist.tar
mv dist_* backup/
mv dist.tar "dist_\$(date '+%Y%m%d%H%M%S').tar"
cd backup/
ls -t | tail -n +6 | xargs rm
""",
execTimeout: 120000,
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: "/$REMOTE_PATH",
remoteDirectorySDF: false,
removePrefix: '',
sourceFiles: 'dist.tar'
)
],
usePromotionTimestamp: false,
useWorkspaceInPromotion: false,
verbose: true
)
]
)
}
}
}
post {
success {
echo "========pipeline executed successfully ========"
}
failure {
echo "========pipeline executed failed ========"
}
}
}