forked from javahometech/myweb
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Jenkins-docker
59 lines (55 loc) · 1.82 KB
/
Jenkins-docker
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
pipeline{
agent any
tools {
maven 'Maven-3.6.1'
}
environment{
PATH = "/opt/maven3/bin:$PATH"
}
stages{
stage("Git Checkout"){
steps{
git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git'
}
}
stage("Maven Build"){
steps{
sh "mvn clean sonar:sonar package"
}
}
stage('Upload War To Nexus'){
steps{
nexusArtifactUploader artifacts: [
[
artifactId: 'myweb',
classifier: '',
file: "target/myweb-8.2.0.war",
type: 'war'
]
],
credentialsId: 'nexus3',
groupId: 'in.javahome',
nexusUrl: '172.31.36.181:8081',
nexusVersion: 'nexus3',
protocol: 'http',
repository: 'sample-releases',
version: '8.2.0'
}
}
stage('Build Docker Image'){
steps{
sh 'docker build -t deepikac2021/spring-boot-mongo .'
sh 'docker build -t tomcat:${BUILD_NUMBER} .'
sh 'docker run -itd --name srini36 -p 2900:8080 tomcat:${BUILD_NUMBER}'
}
}
stage('Push Docker Image'){
steps{
withCredentials([string(credentialsId: 'DOCKER_HUB_CREDENTIALS', variable: 'DOCKER_HUB_CREDENTIALS')]) {
sh "docker login -u deepikac2021 -p ${DOCKER_HUB_CREDENTIALS}"
}
sh 'docker push deepikac2021/spring-boot-mongo'
}
}
}
}