forked from damodaranj/my-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
41 lines (40 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
node{
stage('SCM Checkout'){
git 'https://github.com/damodaranj/my-app.git'
}
stage('Compile-Package'){
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 Imager'){
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 13.233.192.31:8083"
sh "docker tag saidamo/myweb:0.0.2 13.233.192.31:8083/damo:1.0.0"
sh 'docker push 13.233.192.31:8083/damo: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'
}
}
}