forked from damodaranj/my-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
42 lines (39 loc) · 1.21 KB
/
Jenkinsfile
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
node{
stage('SCM Checkout'){
git 'https://github.com/damodaranj/my-app.git'
}
stage('maven-buildstage'){
def mvnHome = tool name: 'maven3', type: 'maven'
sh "${mvnHome}/bin/mvn clean package"
sh 'mv target/myweb*.war target/newapp.war'
}
stage('SonarQube Analysis') {
def mvnHome = tool name: 'maven3', type: 'maven'
withSonarQubeEnv('sonar') {
sh "${mvnHome}/bin/mvn sonar:sonar"
}
}
stage('Build Docker Image'){
sh 'docker build -t saidamo/myweb:0.0.2 .'
}
stage('Docker Image Push'){
withCredentials([string(credentialsId: 'dockerPass', variable: 'dockerPassword')]) {
sh "docker login -u saidamo -p ${dockerPassword}"
}
sh 'docker push saidamo/myweb:0.0.2'
}
stage('Nexus Image Push'){
sh "docker login -u admin -p admin123 15.207.14.16:808"
sh "docker tag prasanna451/myweb:0.0.2 15.207.14.16:808/press:1.0.0"
sh 'docker push 15.207.14.16:8083/press:1.0.0'
}
stage('Remove Previous Container'){
try{
sh 'docker rm -f tomcattest'
}catch(error){
// do nothing if there is an exception
}
stage('Docker deployment'){
sh 'docker run -d -p 8090:8080 --name tomcattest saidamo/myweb:0.0.2'
}
}