forked from rajarajan250797/damodaranj-new-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
41 lines (40 loc) · 1.23 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/iyalkeerthana/damodaranj-new-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 iyalkavi/myweb:0.0.2 .'
}
stage('Docker Image Push'){
withCredentials([string(credentialsId: 'dockerPass', variable: 'dockerPassword')]) {
sh "docker login -u iyalkavi -p ${dockerPassword}"
}
sh 'docker push iyalkavi/myweb:0.0.2'
}
stage('Nexus Image Push'){
sh "docker login -u admin -p admin123 3.88.220.104:8083"
sh "docker tag iyalkavi/myweb:0.0.2 3.88.220.104:8083/iyal:1.0.0"
sh 'docker push 3.88.220.104:8083/iyal: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 iyalkavi/myweb:0.0.2'
}
}
}