Skip to content

Commit eea94e7

Browse files
authored
Create jenkinsfile.groovy
1 parent 0d69895 commit eea94e7

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

jenkinsfile.groovy

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
node('java') {
2+
3+
stage('Checkout') {
4+
checkout([$class: 'GitSCM',
5+
branches: [[name: 'main']],
6+
userRemoteConfigs: [[url: 'https://github.com/BinduPrivate/java-example.git']]
7+
])
8+
}
9+
10+
stage('Test') {
11+
try {
12+
sh 'mvn clean test'
13+
echo 'Running unit test and integration test'
14+
} catch (Exception e) {
15+
error 'Tests failed!'
16+
}
17+
}
18+
19+
stage('Build') {
20+
try {
21+
sh 'mvn clean package'
22+
echo 'Build successful'
23+
} catch (Exception e) {
24+
error 'Build failed!'
25+
}
26+
}
27+
28+
stage('Deploy') {
29+
try {
30+
31+
sh 'sudo rsync -av /home/ubuntu/jenkins/workspace/artifact-deployment/target/works-with-heroku-1.0.war /opt/apache-tomcat-9.0.96/webapps'
32+
echo 'Successfully deployed'
33+
} catch (Exception e) {
34+
error 'Deployment failed!'
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)