List of commits:
Subject Hash Author Date (UTC)
changes for logic of comparision. f854bbc4abedf7e4db3178d6394be70f252ea2d6 chatta06 2019-02-12 15:56:43
Snapshot impl 6ae9413b66358a4dbf9144aaade3828cc5a1aa8b mandas04 2019-02-04 09:40:22
Adding custom Swagger UI c0fa959950e032efd4eee4e84456e0f5a8a667ca mandas04 2019-02-02 14:58:01
Refactor build.gradle 0348a38a7bc46a35a466d59c3f67bbb0e430493d mandas04 2019-02-02 11:00:49
Updating code covergae ratio check to 90% 49684bdc879b14c55bd080a381827938fa44b56a mandas04 2019-02-01 10:36:37
[AP] Set jvm args to make builds faster 34c27cf2d35d97d82d06a6a675561843b389552b Pai, Ashwin 2019-02-01 10:05:55
Excluding models from code coverage reprot f22c7d1833e8c9a36057894195294c174334e03d mandas04 2019-02-01 09:37:57
Update sanity check URL for prod c499fd864c92cf5e01187270f3ab8bbfcc05faed mandas04 2019-02-01 04:48:11
[AP] Adding sanity test in dev & prod ceeabd906af4e2cf2266fa6429fb6a0cef916dce Pai, Ashwin 2019-01-31 20:14:35
[AP] Check runList exist before accessing it. 182194ab3988dbd0049005dc97be0cfbdbf16fd0 Pai, Ashwin 2019-01-31 17:34:03
[AP] Get runList var from the -P command line 5b6699ca61da8597ba3a7900ab0d14e1b9f35a44 Pai, Ashwin 2019-01-31 17:26:19
[AP] Fix the credential id for gitlab 9bba45b10eb93688e11435219a7cdffafbbee8d7 Pai, Ashwin 2019-01-31 17:18:45
Refactor Jenkins cred 36acd3adbb192d251ccdc83802fc6a54798d3493 mandas04 2019-01-31 15:55:35
Update test cases 351a1f00250e293ff49fd66c852a3bced9c296be mandas04 2019-01-31 15:21:06
Skipped testing during gradle build 37352f5b876e311a19a8b2aea5759c9c1be8f037 mandas04 2019-01-31 13:29:27
Adjust JaCoCo test coverage 3eca68000e279756223fc5d27accf3a12988ad1d mandas04 2019-01-31 13:17:55
update resttemplate configurations bd1da0c99a2f97c0f7ac1537121a093b7229cba5 mandas04 2019-01-31 13:10:04
Refactor test packages ddc3aae04e4ebceb21b5a421813be6e0cc7733ad mandas04 2019-01-31 11:46:57
Refactoring Test packages e916b5f3f15beb28f5a7373bc046cc81fb2b7630 mandas04 2019-01-31 04:36:10
Refactor DockerFile 90de083d4cb6128977b761994a02b244c8d3cf6c mandas04 2019-01-30 14:31:54
Commit f854bbc4abedf7e4db3178d6394be70f252ea2d6 - changes for logic of comparision.
Author: chatta06
Author date (UTC): 2019-02-12 15:56
Committer name: chatta06
Committer date (UTC): 2019-02-12 15:56
Parent(s): 6ae9413b66358a4dbf9144aaade3828cc5a1aa8b
Signing key:
Tree: ec549e18d67e7d1706077da153b57bcf73d2c28d
File Lines added Lines deleted
src/main/java/com/kingfisher/deployment/audit/data/builder/DeploymentStatusBuidler.java 61 9
src/main/java/com/kingfisher/deployment/audit/model/Deployment.java 18 2
src/main/java/com/kingfisher/deployment/audit/service/DeploymentAuditService.java 18 8
File src/main/java/com/kingfisher/deployment/audit/data/builder/DeploymentStatusBuidler.java changed (mode: 100644) (index cc938fb..ec099ec)
... ... package com.kingfisher.deployment.audit.data.builder;
3 3 import java.text.ParseException; import java.text.ParseException;
4 4 import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
5 5 import java.util.ArrayList; import java.util.ArrayList;
6 import java.util.Collections;
6 7 import java.util.Date; import java.util.Date;
7 8 import java.util.List; import java.util.List;
8 9
 
... ... import com.kingfisher.deployment.audit.model.JenkinsDeploymentStatus;
24 25 import com.kingfisher.deployment.audit.repository.InstanceRepository; import com.kingfisher.deployment.audit.repository.InstanceRepository;
25 26 import com.kingfisher.deployment.audit.rest.client.IIBRestClient; import com.kingfisher.deployment.audit.rest.client.IIBRestClient;
26 27 import com.kingfisher.deployment.audit.security.PasswordCodec; import com.kingfisher.deployment.audit.security.PasswordCodec;
27 import com.kingfisher.deployment.audit.test.util.IntegrationTestUtil;
28 28
29 29 @Component @Component
30 30 public class DeploymentStatusBuidler { public class DeploymentStatusBuidler {
 
... ... public class DeploymentStatusBuidler {
48 48 String createdByProcess = jenkinsDeploymentStatus.getCreatedByProcess(); String createdByProcess = jenkinsDeploymentStatus.getCreatedByProcess();
49 49
50 50 Instance instance = instanceRepository.findByInstanceName(instanceName); Instance instance = instanceRepository.findByInstanceName(instanceName);
51 IIBDeploymentStatus iibDeploymentStatus = iibRestClient.getDeployemntProperties(integrationServer, applicationName, instance.getHost(), instance.getApiPort(), instance.getApiUsername(), passwordCodec.decrypt(instance.getApiPassword()));
51 IIBDeploymentStatus iibDeploymentStatus = iibRestClient.getDeployemntProperties(integrationServer,
52 applicationName, instance.getHost(), instance.getApiPort(), instance.getApiUsername(),
53 passwordCodec.decrypt(instance.getApiPassword()));
52 54
53 55 Date barDeploymentTime = getBarDeploymentTime(iibDeploymentStatus); Date barDeploymentTime = getBarDeploymentTime(iibDeploymentStatus);
54 56 Date barModifyTime = getBarModifyTime(iibDeploymentStatus); Date barModifyTime = getBarModifyTime(iibDeploymentStatus);
 
... ... public class DeploymentStatusBuidler {
58 60
59 61 Date createdTime = new Date(); Date createdTime = new Date();
60 62
61 return new Deployment(applicationName, barfileName, environment, instanceName, integrationServer, barDeploymentTime, createdTime, barModifyTime, barReleaseId, barChecksum, deployedByUserName, deployedByUserId, createdByProcess);
63 return new Deployment(applicationName, barfileName, environment, instanceName, integrationServer,
64 barDeploymentTime, createdTime, barModifyTime, barReleaseId, barChecksum, deployedByUserName,
65 deployedByUserId, createdByProcess);
62 66 } }
63 67
64 68 public List<Deployment> getSnapshotFromIIB(final String tier) throws DeploymentAuditException { public List<Deployment> getSnapshotFromIIB(final String tier) throws DeploymentAuditException {
65 69 List<Deployment> iibList = new ArrayList<>(); List<Deployment> iibList = new ArrayList<>();
66 70 List<Instance> instances = instanceRepository.findByTier(tier); List<Instance> instances = instanceRepository.findByTier(tier);
67 71 for (Instance instance : instances) { for (Instance instance : instances) {
68 IntegrationServers integrationServers = iibRestClient.getIntegrationServers(instance.getHost(), instance.getApiPort(), instance.getApiUsername(), passwordCodec.decrypt(instance.getApiPassword()));
72 IntegrationServers integrationServers = iibRestClient.getIntegrationServers(instance.getHost(),
73 instance.getApiPort(), instance.getApiUsername(), passwordCodec.decrypt(instance.getApiPassword()));
69 74 for (IntegrationServer integrationServer : integrationServers.getExecutionGroup()) { for (IntegrationServer integrationServer : integrationServers.getExecutionGroup()) {
70 Applications applications = iibRestClient.getApplications(integrationServer.getName(), instance.getHost(), instance.getApiPort(), instance.getApiUsername(), passwordCodec.decrypt(instance.getApiPassword()));
75 Applications applications = iibRestClient.getApplications(integrationServer.getName(),
76 instance.getHost(), instance.getApiPort(), instance.getApiUsername(),
77 passwordCodec.decrypt(instance.getApiPassword()));
71 78 for (Application application : applications.getApplication()) { for (Application application : applications.getApplication()) {
72 IIBDeploymentStatus iibDeploymentStatus = iibRestClient.getDeployemntProperties(integrationServer.getName(), application.getName(), instance.getHost(), instance.getApiPort(), instance.getApiUsername(), passwordCodec.decrypt(instance.getApiPassword()));
73 iibList.add(new Deployment(application.getName(), getBarFileName(iibDeploymentStatus), instance.getTier(), instance.getInstanceName(), integrationServer.getName(), getBarDeploymentTime(iibDeploymentStatus), new Date(), getBarModifyTime(iibDeploymentStatus), getBarReleaseId(iibDeploymentStatus), getBarCheckSum(iibDeploymentStatus), "api", "api", "snapshot"));
79 IIBDeploymentStatus iibDeploymentStatus = iibRestClient.getDeployemntProperties(
80 integrationServer.getName(), application.getName(), instance.getHost(),
81 instance.getApiPort(), instance.getApiUsername(),
82 passwordCodec.decrypt(instance.getApiPassword()));
83 iibList.add(new Deployment(application.getName(), getBarFileName(iibDeploymentStatus),
84 instance.getTier(), instance.getInstanceName(), integrationServer.getName(),
85 getBarDeploymentTime(iibDeploymentStatus), new Date(),
86 getBarModifyTime(iibDeploymentStatus), getBarReleaseId(iibDeploymentStatus),
87 getBarCheckSum(iibDeploymentStatus), "api", "api", "snapshot"));
74 88 } }
75 89 } }
76 90 } }
77 91 return iibList; return iibList;
78 92 } }
79 93
80 public void compareDeploymentsAndRectify(final List<Deployment> iibList, final List<Deployment> dbList) {
94 public List<Deployment> compareDeploymentsAndRectify(final List<Deployment> iibList,
95 final List<Deployment> dbList) {
96 List<Deployment> deploymentToBeUpdated = new ArrayList<>();
81 97 List<IndexedDeployment> iibIndexedList = indexDeployment(iibList); List<IndexedDeployment> iibIndexedList = indexDeployment(iibList);
82 98 List<IndexedDeployment> dbIndexedList = indexDeployment(dbList); List<IndexedDeployment> dbIndexedList = indexDeployment(dbList);
83
99 Collections.sort(iibIndexedList);
100 Collections.sort(dbIndexedList);
101
102 for (IndexedDeployment iibDeployment : iibIndexedList) {
103 boolean deploymentMatched = false;
104 IndexedDeployment matchedDBDeployment = null;
105 for (IndexedDeployment dbDeployment : dbIndexedList) {
106 if (iibDeployment.getIndex().equals(dbDeployment.getIndex())) {
107 deploymentMatched = true;
108 matchedDBDeployment = dbDeployment;
109
110 if (!iibDeployment.getDeployment().getBarDeploymentTime()
111 .equals(dbDeployment.getDeployment().getBarDeploymentTime())) {
112 dbDeployment.getDeployment().setExcludeFromReport(true);
113 deploymentToBeUpdated.add(dbDeployment.getDeployment());
114 deploymentToBeUpdated.add(iibDeployment.getDeployment());
115 }
116
117 break;
118 }
119 if (iibDeployment.compareTo(dbDeployment) < 0)
120 break;
121 }
122 if (deploymentMatched) {
123 dbIndexedList.remove(matchedDBDeployment);
124 } else {
125 deploymentToBeUpdated.add(iibDeployment.getDeployment());
126 }
127 }
128
129 for (IndexedDeployment dbDeployment : dbIndexedList) {
130 dbDeployment.getDeployment().setExcludeFromReport(true);
131 dbDeployment.getDeployment().setBarDeleted(true);
132 deploymentToBeUpdated.add(dbDeployment.getDeployment());
133 }
134
135 return deploymentToBeUpdated;
84 136 } }
85 137
86 138 private List<IndexedDeployment> indexDeployment(final List<Deployment> deployments) { private List<IndexedDeployment> indexDeployment(final List<Deployment> deployments) {
File src/main/java/com/kingfisher/deployment/audit/model/Deployment.java changed (mode: 100644) (index 7f7088a..33de171)
... ... public class Deployment {
70 70 public Deployment() { public Deployment() {
71 71 } }
72 72
73 public Deployment(String applicationName, String barfileName, String environment, String instanceName, String integrationServer, Date barDeploymentTime, Date createdTime, Date barModifyTime, String barReleaseId, String barChecksum, String deployedByUserName, String deployedByUserId, String createdByProcess) {
73 public Deployment(String applicationName, String barfileName, String environment, String instanceName,
74 String integrationServer, Date barDeploymentTime, Date createdTime, Date barModifyTime, String barReleaseId,
75 String barChecksum, String deployedByUserName, String deployedByUserId, String createdByProcess) {
74 76 this.applicationName = applicationName; this.applicationName = applicationName;
75 77 this.barfileName = barfileName; this.barfileName = barfileName;
76 78 this.environment = environment; this.environment = environment;
 
... ... public class Deployment {
206 208 this.excludeFromReport = excludeFromReport; this.excludeFromReport = excludeFromReport;
207 209 } }
208 210
211 public boolean isBarDeleted() {
212 return barDeleted;
213 }
214
215 public void setBarDeleted(boolean barDeleted) {
216 this.barDeleted = barDeleted;
217 }
218
209 219 @Override @Override
210 220 public String toString() { public String toString() {
211 return "Deployment [deploymentId=" + deploymentId + ", applicationName=" + applicationName + ", barfileName=" + barfileName + ", environment=" + environment + ", instanceName=" + instanceName + ", integrationServer=" + integrationServer + ", barDeploymentTime=" + barDeploymentTime + ", createdTime=" + createdTime + ", barModifyTime=" + barModifyTime + ", barReleaseId=" + barReleaseId + ", barChecksum=" + barChecksum + ", deployedByUserName=" + deployedByUserName + ", deployedByUserId=" + deployedByUserId + ", createdByProcess=" + createdByProcess + ", barDeleted=" + barDeleted + ", excludeFromReport=" + excludeFromReport + "]";
221 return "Deployment [deploymentId=" + deploymentId + ", applicationName=" + applicationName + ", barfileName="
222 + barfileName + ", environment=" + environment + ", instanceName=" + instanceName
223 + ", integrationServer=" + integrationServer + ", barDeploymentTime=" + barDeploymentTime
224 + ", createdTime=" + createdTime + ", barModifyTime=" + barModifyTime + ", barReleaseId=" + barReleaseId
225 + ", barChecksum=" + barChecksum + ", deployedByUserName=" + deployedByUserName + ", deployedByUserId="
226 + deployedByUserId + ", createdByProcess=" + createdByProcess + ", barDeleted=" + barDeleted
227 + ", excludeFromReport=" + excludeFromReport + "]";
212 228 } }
213 229
214 230 } }
File src/main/java/com/kingfisher/deployment/audit/service/DeploymentAuditService.java changed (mode: 100644) (index b7133ef..b7567fc)
... ... import org.springframework.stereotype.Service;
14 14 import com.kingfisher.deployment.audit.data.builder.DeploymentStatusBuidler; import com.kingfisher.deployment.audit.data.builder.DeploymentStatusBuidler;
15 15 import com.kingfisher.deployment.audit.exception.model.DeploymentAuditException; import com.kingfisher.deployment.audit.exception.model.DeploymentAuditException;
16 16 import com.kingfisher.deployment.audit.model.Deployment; import com.kingfisher.deployment.audit.model.Deployment;
17 import com.kingfisher.deployment.audit.model.IndexedDeployment;
18 17 import com.kingfisher.deployment.audit.model.JenkinsDeploymentStatus; import com.kingfisher.deployment.audit.model.JenkinsDeploymentStatus;
19 18 import com.kingfisher.deployment.audit.report.builder.ExcelReportBuilder; import com.kingfisher.deployment.audit.report.builder.ExcelReportBuilder;
20 19 import com.kingfisher.deployment.audit.repository.DeploymentRepository; import com.kingfisher.deployment.audit.repository.DeploymentRepository;
 
... ... public class DeploymentAuditService {
65 64 * @return * @return
66 65 * @throws DeploymentAuditException * @throws DeploymentAuditException
67 66 */ */
68 private Map<String, List<Deployment>> prepareDataForApplication(String application, String referenceEnv, List<String> reportingEnvs) throws DeploymentAuditException {
67 private Map<String, List<Deployment>> prepareDataForApplication(String application, String referenceEnv,
68 List<String> reportingEnvs) throws DeploymentAuditException {
69 69 Map<String, List<Deployment>> latestDeploymentsInEnvironmentForApplication = new LinkedHashMap<>(); Map<String, List<Deployment>> latestDeploymentsInEnvironmentForApplication = new LinkedHashMap<>();
70 latestDeploymentsInEnvironmentForApplication.put(referenceEnv, deploymentRepository.findLatestDeploymentByApplicationNameAndEnvironment(referenceEnv, application));
70 latestDeploymentsInEnvironmentForApplication.put(referenceEnv,
71 deploymentRepository.findLatestDeploymentByApplicationNameAndEnvironment(referenceEnv, application));
71 72 for (String reportingEnv : reportingEnvs) for (String reportingEnv : reportingEnvs)
72 latestDeploymentsInEnvironmentForApplication.put(reportingEnv, deploymentRepository.findLatestDeploymentByApplicationNameAndEnvironment(reportingEnv, application));
73 latestDeploymentsInEnvironmentForApplication.put(reportingEnv, deploymentRepository
74 .findLatestDeploymentByApplicationNameAndEnvironment(reportingEnv, application));
73 75 return latestDeploymentsInEnvironmentForApplication; return latestDeploymentsInEnvironmentForApplication;
74 76 } }
75 77
 
... ... public class DeploymentAuditService {
81 83 * @return * @return
82 84 * @throws DeploymentAuditException * @throws DeploymentAuditException
83 85 */ */
84 public void recordDeployments(List<JenkinsDeploymentStatus> jenkinsDeploymentStatuses) throws DeploymentAuditException {
86 public void recordDeployments(List<JenkinsDeploymentStatus> jenkinsDeploymentStatuses)
87 throws DeploymentAuditException {
85 88 List<Deployment> deployments = new ArrayList<>(); List<Deployment> deployments = new ArrayList<>();
86 89 for (JenkinsDeploymentStatus jenkinsDeploymentStatus : jenkinsDeploymentStatuses) { for (JenkinsDeploymentStatus jenkinsDeploymentStatus : jenkinsDeploymentStatuses) {
87 90 Deployment deployment = deploymentStatusBuidler.build(jenkinsDeploymentStatus); Deployment deployment = deploymentStatusBuidler.build(jenkinsDeploymentStatus);
88 if (deploymentRepository.findByApplicationNameAndInstanceNameAndIntegrationServerAndBarDeploymentTime(deployment.getApplicationName(), deployment.getInstanceName(), deployment.getIntegrationServer(), deployment.getBarDeploymentTime()).equals(Optional.empty())) {
89 deploymentRepository.hideFromReport(deployment.getApplicationName(), deployment.getInstanceName(), deployment.getIntegrationServer());
91 if (deploymentRepository
92 .findByApplicationNameAndInstanceNameAndIntegrationServerAndBarDeploymentTime(
93 deployment.getApplicationName(), deployment.getInstanceName(),
94 deployment.getIntegrationServer(), deployment.getBarDeploymentTime())
95 .equals(Optional.empty())) {
96 deploymentRepository.hideFromReport(deployment.getApplicationName(), deployment.getInstanceName(),
97 deployment.getIntegrationServer());
90 98 deployments.add(deployment); deployments.add(deployment);
91 99 } }
92 100 } }
 
... ... public class DeploymentAuditService {
105 113 public void createSnapshot(String tier) throws DeploymentAuditException { public void createSnapshot(String tier) throws DeploymentAuditException {
106 114 List<Deployment> iibList = deploymentStatusBuidler.getSnapshotFromIIB(tier); List<Deployment> iibList = deploymentStatusBuidler.getSnapshotFromIIB(tier);
107 115 List<Deployment> dbList = deploymentRepository.findAllInReport(tier); List<Deployment> dbList = deploymentRepository.findAllInReport(tier);
108 deploymentStatusBuidler.compareDeploymentsAndRectify(iibList, dbList);
116 for (Deployment deployment : deploymentStatusBuidler.compareDeploymentsAndRectify(iibList, dbList)) {
117 deploymentRepository.save(deployment);
118 }
109 119 } }
110 120
111 121 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/Sumangal-IN/deployment-audit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/Sumangal-IN/deployment-audit

Clone this repository using git:
git clone git://git.rocketgit.com/user/Sumangal-IN/deployment-audit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main