-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjava-jenkinsfile
More file actions
88 lines (83 loc) · 3 KB
/
java-jenkinsfile
File metadata and controls
88 lines (83 loc) · 3 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
pipeline {
agent any
tools {
maven 'maven'
}
stages {
stage('Parallel Execution') {
parallel {
stage('Pipeline 1 Execution') {
stages {
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/Coding4Deep/Nodejs-Java-Project.git'
}
}
stage('Compile') {
steps {
sh 'mvn compile'
}
}
stage('Unit Test') {
steps {
sh 'mvn test'
}
}
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv('SonarQube') {
sh 'mvn sonar:sonar jacoco:report'
}
}
}
stage('Nexus') {
steps {
sh 'mvn clean package deploy'
}
}
stage('Deploy to Tomcat') {
steps {
sshagent(['vagrant-loacal-ssh']) {
sh "scp -o StrictHostKeyChecking=no target/JAVA-PROJECT.war vagrant@192.168.33.11:/opt/tomcat/webapps/"
}
}
}
}
}
stage('Pipeline 2 Execution') {
steps {
build job: 'NODEJS-PROJECT'
}
}
}
}
}
post {
success {
echo "Publishing JUnit test report to Jenkins UI"
junit '**/target/surefire-reports/*.xml'
slackSend(
channel: '#javanodeprojects',
color: 'good',
message: "✅ *Build Successful!*\nJob: ${env.JOB_NAME} #${env.BUILD_NUMBER}\nBranch: ${env.GIT_BRANCH}\nURL: ${env.BUILD_URL}"
)
}
failure {
slackSend(
channel: '#javanodeprojects',
color: 'danger',
message: "❌ *Build Failed!*\nJob: ${env.JOB_NAME} #${env.BUILD_NUMBER}\nBranch: ${env.GIT_BRANCH}\nURL: ${env.BUILD_URL}"
)
}
always {
echo "Publishing JaCoCo coverage report to Jenkins UI"
jacoco(
execPattern: '**/target/jacoco.exec',
classPattern: '**/target/classes',
sourcePattern: '**/src/main/java',
inclusionPattern: '**/*.class',
exclusionPattern: '**/test/*.class'
)
}
}
}