forked from MithunTechnologiesDevOps/java-web-app-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
executable file
·177 lines (157 loc) · 6.04 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
pipeline {
agent any
tools {
maven 'MAVEN'
}
// environment {
// AWS_ACCOUNT_ID= "803561623563"
// AWS_DEFAULT_REGION="ap-south-1"
// IMAGE_REPO_NAME= "ecrpipeline"
// IMAGE_TAG= "latest"
// REPOSITORY_URI= "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${IMAGE_REPO_NAME}"
// }
stages {
stage('SCM Checkout') {
steps {
git 'https://github.com/shrasyntex00/java-web-app.git'
}
}
// stage('Unit Testing') {
// steps {
// sh 'mvn test'
// }
// }
// stage('Integration Testing'){
// steps {
// sh 'mvn verify -DskipUnitTests'
// }
// }
// stage('SonarQube Analysis'){
// steps {
// withSonarQubeEnv(installationName: 'sonarcred') {
// sh 'mvn sonar:sonar'
// }
// }
// }
// stage('clean and install'){
// steps {
// sh 'mvn clean install'
// }
// }
stage('Build') {
steps {
sh 'mvn clean package'
}
}
// stage('Upload war to Nexus'){
// steps {
// nexusArtifactUploader artifacts: [
// [
// artifactId: 'java-web-app',
// classifier: '',
// file: 'target/java-web-app-1.0.0.war',
// type: 'war'
// ]
// ],
// credentialsId: 'nexuscredentials',
// groupId: 'com.mt',
// nexusUrl: '3.80.69.190:8081',
// nexusVersion: 'nexus3',
// protocol: 'http',
// repository: 'test-release',
// version: '1.0.0'
// }
// }
// stage('sonar Analysis') {
// steps{
// withSonarQubeEnv('Sonarqube') {
// sh 'mvn clean verify sonar:sonar \
// -Dsonar.projectName=demoapp \
// -Dsonar.projectKey=demoapp1 \
// -Dsonar.login=squ_6ace97895693536eb385118edb96f74deb42faa4 \
// -Dsonar.host.url=http://52.200.137.65:9000'
// }
// }
// }
// stage('Quality Gate Analysis'){
// steps {
// waitForQualityGate abortPipeline: true
// }
// }
// stage('push nexus artifact'){
// steps {
// sh 'mvn clean deploy'
// }
// }
// stage('deploy to tomcat') {
// steps {
// deploy adapters: [tomcat9(credentialsId: 'tomcatcred', path: '', url: 'http://15.168.8.30:8080/')], contextPath: null, war: '**/*.war'
// }
// }
// stage('Upload war to Nexus'){
// steps {
// script{
// def readPomVersion = readMavenPom file: 'pom.xml'
// // def nexusRepo = readPomVersion.version.endsWith("RELEASE") ? "skan-snapshot" : "skanjob"
// nexusArtifactUploader artifacts: [
// [
// artifactId: 'java-web-app',
// classifier: '',
// file: "target/java-web-app-${readPomVersion.version}.war",
// type: 'war'
// ]
// ],
// credentialsId: 'nexuscredentials',
// groupId: 'com.mt',
// nexusUrl: '54.164.112.132:8081',
// nexusVersion: 'nexus3',
// protocol: 'http',
// repository: 'test-release',
// version: "${readPomVersion.version}"
// }
// }
// }
// stage('deploy with ansible'){
// steps {
// ansiblePlaybook credentialsId: 'ansiblecredentials', disableHostKeyChecking: true, installation: 'ansible', inventory: 'hosts.inv', playbook: 'deployjava.yaml'
// }
// }
// stage('build docker image') {
// steps {
// script{
// dockerImage = docker.build "${IMAGE_REPO_NAME}:${IMAGE_TAG}"
// }
// }
// }
// stage('DockerHUB LOGIN & push image') {
// steps {
// withCredentials([string(credentialsId: 'dockerhub-credentials', variable: 'dockerhubcredentials')]) {
// sh "docker login -u account1996 -p ${dockerhubcredentials}"
// }
// sh 'docker push account1996/java:1'
// }
// }
// stage('Loggingto AWS ECR') {
// steps {
// sh "aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 803561623563.dkr.ecr.ap-south-1.amazonaws.com"
// }
// }
// stage('Pushingto ECR') {
// steps{
// sh "docker build -t ecrpipeline ."
// sh "docker tag ecrpipeline:latest 803561623563.dkr.ecr.ap-south-1.amazonaws.com/ecrpipeline:latest"
// sh "docker push 803561623563.dkr.ecr.ap-south-1.amazonaws.com/ecrpipeline:latest"
// }
// }
// stage('K8S Deploy'){
// steps{
// // kubernetesDeploy(
// // config: 'java-web-app-docker/javawebapp-deployment.yml',
// // kubeconfigId:'K8S',
// // enableConfigSubstitution: true
// // )
// sh 'kubectl apply -f javawebapp-deployment.yml'
// }
// }
}
}