-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathJenkinsfile2
109 lines (96 loc) · 2.05 KB
/
Jenkinsfile2
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
pipeline
{
agent any
environment {
DOCKERHUB_CREDENTIALS = credentials('Cloud-Gen-Docker-Hub')
}
tools
{
maven "maven"
}
stages{
stage('Code Checkout'){
steps{
git branch: 'main', url: 'https://github.com/Devops9AM/Rigstration-Form.git'
}
}
stage("SonarQube analysis") {
steps {
withSonarQubeEnv('sonar') {
sh 'mvn clean install sonar:sonar'
}
}
}
stage('Maven Plugins Install'){
steps{
sh 'mvn install'
}
}
stage('Code Verify by Maven'){
steps{
sh 'mvn verify'
}
}
stage('Maven Clode Validate'){
steps{
sh 'mvn validate'
}
}
stage('Code Test by Maven'){
steps{
sh 'mvn test'
}
}
stage('Code Compile by Maven'){
steps{
sh 'mvn compile'
}
}
stage('Cleaning the Old Artifact'){
steps{
sh 'mvn clean'
}
}
stage('War Build'){
steps{
sh 'mvn package'
}
}
stage('Deploy War to Nexus'){
steps{
sh 'mvn deploy'
}
}
stage ('DEV Deploy to Tomcat') {
steps{
echo "deploying to DEV Env "
deploy adapters: [tomcat9(credentialsId: 'war-deploy-to-tomcat', path: '', url: 'http://192.168.10.169:8080')], contextPath: null, war: '**/*.war'
}
}
stage('Copying Packge'){
steps{
sh 'cp /root/.jenkins/workspace/nexus-tomcat-docker-project/webapp/target/webapp.war /root/.jenkins/workspace/nexus-tomcat-docker-project/'
}
}
stage('Build docker image') {
steps {
sh 'docker build -t thanish/registration-form:$BUILD_NUMBER .'
}
}
stage('login to dockerhub') {
steps{
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
}
}
stage('push image') {
steps{
sh 'docker push thanish/registration-form:$BUILD_NUMBER'
}
}
}
post {
always {
sh 'docker logout'
}
}
}