forked from sudheer76R/java-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjenkinsfile.groovy
More file actions
33 lines (25 loc) · 834 Bytes
/
jenkinsfile.groovy
File metadata and controls
33 lines (25 loc) · 834 Bytes
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
node('agent1') {
def mvnHome
def tomcatUser = 'ubuntu'
def tomcatHost = '172.31.9.248'
def tomcatPath = '/home/ubuntu/tomcat/webapps/'
stage('Checkout') {
// Checkout source code from Git
checkout([
branches: [[name: '*/main']], // Correct format for branch name
userRemoteConfigs: [[url: 'https://github.com/guruvenkatakrishna/java-example.git' ]]
])
}
stage('Build') {
// Set Maven tool
mvnHome = tool 'Maven'
// Run Maven build
sh "'${mvnHome}/bin/mvn' clean package"
// Archive the build artifacts
archiveArtifacts artifacts: '**/target/*.war'
}
stage('Deploy') {
// Copy the WAR file to the Tomcat webapps directory
sh "sudo cp /home/ubuntu/jenkins/workspace/jenkinsfile.groovy/target/*.war ${tomcatPath}"
}
}