forked from sudheer76R/java-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
43 lines (43 loc) · 1.15 KB
/
Jenkinsfile
File metadata and controls
43 lines (43 loc) · 1.15 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
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/guruvenkatakrishna/jenkinspipeline.git'
}
}
stage('Code Analysis') {
steps {
sh 'mvn clean verify sonar:sonar'
}
}
stage('Unit Testing') {
steps {
sh 'mvn test'
}
}
stage('Build Artifact') {
steps {
sh 'mvn package'
}
}
stage('Docker Build') {
steps {
sh 'docker build -t app:latest .'
}
}
stage('Push to Docker Hub') {
steps {
withCredentials([usernamePassword(credentialsId: 'docker-cred', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'docker login -u $USERNAME -p $PASSWORD'
sh 'docker push app:latest'
}
}
}
stage('Deploy') {
steps {
sh 'docker run -d -p 8080:8080 app:latest'
}
}
}
}