-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
41 lines (36 loc) · 1.1 KB
/
Jenkinsfile
File metadata and controls
41 lines (36 loc) · 1.1 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
pipeline {
agent any
environment {
SONAR_URL = 'http://localhost:9000'
SONAR_TOKEN = credentials('squ_4988886d9bcf62ae3aa087138e6c0c82e3466349') // Replace with your credential ID
TOMCAT_PATH = '/opt/tomcat/webapps/'
}
stages {
stage('Clone Repository') {
steps {
git credentialsId: 'rupanshi01',
url: 'https://github.com/rupanshi01/devopsproj.git',
branch: 'main'
}
}
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv('SonarQube') {
sh 'mvn sonar:sonar -Dsonar.projectKey=myapp -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_TOKEN'
}
}
}
stage('Deploy to Tomcat') {
steps {
sh 'cp target/myapp.war $TOMCAT_PATH'
sh '/opt/tomcat/bin/shutdown.sh'
sh '/opt/tomcat/bin/startup.sh'
}
}
}
}