-
Notifications
You must be signed in to change notification settings - Fork 628
/
Copy pathjenkins file
60 lines (54 loc) · 1.74 KB
/
jenkins file
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
pipeline {
agent any
environment {
// Define any environment variables here
PROJECT_NAME = "E-commerce-project-springBoot"
GITHUB_REPO_URL = "https://github.com/jaygajera17/E-commerce-project-springBoot.git"
}
stages {
stage('Checkout') {
steps {
// Checkout the code from the GitHub repository
git url: "${GITHUB_REPO_URL}", branch: 'main'
}
}
stage('Build') {
steps {
// Build the project using Maven
sh 'mvn clean package'
}
}
stage('Test') {
steps {
// Run the tests
sh 'mvn test'
}
}
stage('Deploy') {
steps {
// Deploy the application (this can be customized as per your deployment process)
// For example, copying the built JAR file to a specific location, or deploying to a cloud service
sh '''
echo "Deploying application..."
# Example command: copying the built JAR file to a remote server
# scp target/*.jar user@remote-server:/path/to/deployment/directory
'''
}
}
}
post {
always {
// Actions to perform at the end of the pipeline
// For example, cleaning up workspace, sending notifications, etc.
cleanWs()
}
success {
// Actions to perform if the pipeline succeeds
echo 'Pipeline succeeded!'
}
failure {
// Actions to perform if the pipeline fails
echo 'Pipeline failed!'
}
}
}