-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJenkinsfile
More file actions
71 lines (64 loc) · 1.95 KB
/
Jenkinsfile
File metadata and controls
71 lines (64 loc) · 1.95 KB
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
pipeline {
agent any
environment {
NODE_VERSION = '14' // Specify the Node.js version
NPM_CONFIG_CACHE = '.npm' // Cache for npm
}
stages {
stage('Checkout') {
steps {
// Checkout the code from the repository
git 'https://github.com/yourusername/PiFinance-Core.git' // Replace with your repository URL
}
}
stage('Install Dependencies') {
steps {
// Use Node.js Docker image
script {
docker.image("node:${NODE_VERSION}").inside {
sh 'npm install' // Install dependencies
}
}
}
}
stage('Run Tests') {
steps {
// Run unit tests
script {
docker.image("node:${NODE_VERSION}").inside {
sh 'npm test' // Run tests
}
}
}
}
stage('Build') {
steps {
// Build the application
script {
docker.image("node:${NODE_VERSION}").inside {
sh 'npm run build' // Build the application
}
}
}
}
stage('Deploy') {
steps {
// Deploy the application (this can vary based on your deployment strategy)
script {
// Example: Deploy to a server or cloud service
sh 'ssh user@yourserver "cd /path/to/your/app && git pull && npm install && pm2 restart all"' // Replace with your deployment command
}
}
}
}
post {
success {
// Notify on success
echo 'Pipeline completed successfully!'
}
failure {
// Notify on failure
echo 'Pipeline failed!'
}
}
}