-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
74 lines (66 loc) · 2.12 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
pipeline {
agent any
tools {
nodejs 'node' // Ensure NodeJS is configured in Jenkins
}
stages {
stage('Checkout') {
steps {
git url: 'https://github.com/sagar-subedi/litcord.git', branch: 'develop'
}
}
stage('Install Dependencies') {
steps {
script {
sh 'cd ./frontend-angular && npm install'
}
}
}
stage('Build') {
steps {
script {
sh 'cd ./frontend-angular && npm run build'
}
}
}
//Commented as frontend tests are not prioritized
// stage('Test') {
// steps {
// script {
// sh 'cd ./frontend-angular && npm test'
// }
// }
// }
stage('Deploy') {
steps {
sshPublisher(publishers: [
sshPublisherDesc(
configName: 'Litcord EC2', // This is a predefined SSH configuration in Jenkins.
transfers: [
sshTransfer(
sourceFiles: 'frontend-angular/dist/**', // Specifies the files to transfer. `dist/**` includes all files and folders in the `dist` directory.
removePrefix: 'frontend-angular/dist', // Removes the `dist` prefix from the path during transfer, placing files directly in the target directory.
remoteDirectory: '/dist' // Specifies the destination directory on the EC2 server.
),
sshTransfer(
execCommand: 'sudo cp -r dist/litcord /usr/share/nginx/html'
)
],
verbose: true // Enables detailed output in the build logs for debugging.
)
])
}
}
}
post {
always {
cleanWs() // Clean workspace after build
}
success {
echo 'Build succeeded!'
}
failure {
echo 'Build failed!'
}
}
}