From daab67d8cfaea50cc73833df8e8e6739907ade83 Mon Sep 17 00:00:00 2001 From: Siddharth Bose <32789116+SidBose001@users.noreply.github.com> Date: Fri, 19 Sep 2025 11:53:39 +0530 Subject: [PATCH 01/11] Update UCDeployPublisher.java --- .../plugins/ucdeploy/UCDeployPublisher.java | 422 +++++------------- 1 file changed, 107 insertions(+), 315 deletions(-) diff --git a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java index 8336e41..2611ccd 100644 --- a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java +++ b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java @@ -105,31 +105,15 @@ public UserBlock getAltUser() { } public Boolean altUserChecked() { - if (altUser != null) { - return true; - } - - return false; + return altUser != null; } public String getAltUsername() { - String altUsername = ""; - - if (altUser != null) { - altUsername = altUser.getAltUsername(); - } - - return altUsername; + return altUser != null ? altUser.getAltUsername() : ""; } public Secret getAltPassword() { - Secret altPassword = Secret.fromString(""); - - if (altUser != null) { - altPassword = altUser.getAltPassword(); - } - - return altPassword; + return altUser != null ? altUser.getAltPassword() : Secret.fromString(""); } public VersionBlock getComponent() { @@ -137,203 +121,87 @@ public VersionBlock getComponent() { } public Boolean componentChecked() { - if (component != null) { - return true; - } - - return false; + return component != null; } public String getComponentName() { - String componentName = ""; - - if (component != null) { - componentName = component.getComponentName(); - } - - return componentName; + return component != null ? component.getComponentName() : ""; } public CreateComponentBlock getCreateComponent() { - if (component != null) { - return component.getCreateComponent(); - } - else { - return null; - } + return component != null ? component.getCreateComponent() : null; } public Boolean createComponentChecked() { - if (getCreateComponent() != null) { - return true; - } - - return false; + return getCreateComponent() != null; } public String getComponentTemplate() { - String componentTemplate = ""; - - if (getCreateComponent() != null) { - componentTemplate = getCreateComponent().getComponentTemplate(); - } - - return componentTemplate; + return getCreateComponent() != null ? getCreateComponent().getComponentTemplate() : ""; } public String getComponentApplication() { - String componentApplication = ""; - - if (getCreateComponent() != null) { - componentApplication = getCreateComponent().getComponentApplication(); - } - - return componentApplication; + return getCreateComponent() != null ? getCreateComponent().getComponentApplication() : ""; } public DeliveryBlock getDelivery() { - if (component != null) { - return component.getDelivery(); - } - else { - return null; - } + return component != null ? component.getDelivery() : null; } public String getDeliveryType() { - String deliveryType = ""; - - if (getDelivery() != null) { - deliveryType = getDelivery().getDeliveryType().name(); - } - - return deliveryType; + return getDelivery() != null ? getDelivery().getDeliveryType().name() : ""; } public String getPushVersion() { - String pushVersion = ""; - - if (getDelivery() != null && getDelivery() instanceof Push) { - pushVersion = ((Push)getDelivery()).getPushVersion(); - } - - return pushVersion; + return (getDelivery() instanceof Push) ? ((Push)getDelivery()).getPushVersion() : ""; } public String getBaseDir() { - String baseDir = ""; - - if (getDelivery() != null && getDelivery() instanceof Push) { - baseDir = ((Push)getDelivery()).getBaseDir(); - } - - return baseDir; + return (getDelivery() instanceof Push) ? ((Push)getDelivery()).getBaseDir() : ""; } public String getFileIncludePatterns() { - String fileIncludePatterns = ""; - - if (getDelivery() != null && getDelivery() instanceof Push) { - fileIncludePatterns = ((Push)getDelivery()).getFileIncludePatterns(); - } - - return fileIncludePatterns; + return (getDelivery() instanceof Push) ? ((Push)getDelivery()).getFileIncludePatterns() : ""; } public String getFileExcludePatterns() { - String fileExcludePatterns = ""; - - if (getDelivery() != null && getDelivery() instanceof Push) { - fileExcludePatterns = ((Push)getDelivery()).getFileExcludePatterns(); - } - - return fileExcludePatterns; + return (getDelivery() instanceof Push) ? ((Push)getDelivery()).getFileExcludePatterns() : ""; } public String getExtensions() { - String extensions = ""; - - if (getDelivery() != null && getDelivery() instanceof Push) { - extensions = ((Push)getDelivery()).getExtensions(); - } - - return extensions; + return (getDelivery() instanceof Push) ? ((Push)getDelivery()).getExtensions() : ""; } public String getCharset() { - String charset = ""; - - if (getDelivery() != null && getDelivery() instanceof Push) { - charset = ((Push)getDelivery()).getCharset(); - } - - return charset; + return (getDelivery() instanceof Push) ? ((Push)getDelivery()).getCharset() : ""; } public String getPushProperties() { - String pushProperties = ""; - - if (getDelivery() != null && getDelivery() instanceof Push) { - pushProperties = ((Push)getDelivery()).getPushProperties(); - } - - return pushProperties; + return (getDelivery() instanceof Push) ? ((Push)getDelivery()).getPushProperties() : ""; } public String getPushDescription() { - String pushDescription = ""; - - if (getDelivery() != null && getDelivery() instanceof Push) { - pushDescription = ((Push)getDelivery()).getPushDescription(); - } - - return pushDescription; + return (getDelivery() instanceof Push) ? ((Push)getDelivery()).getPushDescription() : ""; } public Boolean getPushIncremental() { - if (getDelivery() != null && getDelivery() instanceof Push) { - return ((Push)getDelivery()).getPushIncremental(); - } - - return false; + return (getDelivery() instanceof Push) ? ((Push)getDelivery()).getPushIncremental() : false; } public String getPullProperties() { - String pullProperties = ""; - - if (getDelivery() != null && getDelivery() instanceof Pull) { - pullProperties = ((Pull)getDelivery()).getPullProperties(); - } - - return pullProperties; + return (getDelivery() instanceof Pull) ? ((Pull)getDelivery()).getPullProperties() : ""; } public String getpullSourceType() { - String pullSourceType = ""; - - if (getDelivery() != null && getDelivery() instanceof Pull) { - pullSourceType = ((Pull)getDelivery()).getPullSourceType(); - } - - return pullSourceType; + return (getDelivery() instanceof Pull) ? ((Pull)getDelivery()).getPullSourceType() : ""; } public String getPullSourceProperties() { - String pullSourceProperties = ""; - - if (getDelivery() != null && getDelivery() instanceof Pull) { - pullSourceProperties = ((Pull)getDelivery()).getPullSourceProperties(); - } - - return pullSourceProperties; + return (getDelivery() instanceof Pull) ? ((Pull)getDelivery()).getPullSourceProperties() : ""; } public Boolean getPullIncremental() { - if (getDelivery() != null && getDelivery() instanceof Pull) { - return ((Pull)getDelivery()).getPullIncremental(); - } - - return false; + return (getDelivery() instanceof Pull) ? ((Pull)getDelivery()).getPullIncremental() : false; } public DeployBlock getDeploy() { @@ -341,49 +209,23 @@ public DeployBlock getDeploy() { } public Boolean deployChecked() { - if (deploy != null) { - return true; - } - - return false; + return deploy != null; } public String getDeployApp() { - String deployApp = ""; - - if (deploy != null) { - deployApp = deploy.getDeployApp(); - } - - return deployApp; + return deploy != null ? deploy.getDeployApp() : ""; } public String getDeployEnv() { - String deployEnv = ""; - - if (deploy != null) { - deployEnv = deploy.getDeployEnv(); - } - - return deployEnv; + return deploy != null ? deploy.getDeployEnv() : ""; } public String getDeployProc() { - String deployProc = ""; - - if (deploy != null) { - deployProc = deploy.getDeployProc(); - } - - return deployProc; + return deploy != null ? deploy.getDeployProc() : ""; } public Boolean getSkipWait() { - if (deploy != null) { - return deploy.getSkipWait(); - } - - return false; + return deploy != null ? deploy.getSkipWait() : false; } public CreateProcessBlock getCreateProcess() { @@ -391,34 +233,19 @@ public CreateProcessBlock getCreateProcess() { } public Boolean createProcessChecked() { - if (getCreateProcess() != null) { - return true; - } - - return false; + return getCreateProcess() != null; } - public CreateSnapshotComponentBlock getSnapshotComponent() { return deploy.getSnapshotComponent(); } - + public Boolean createSnapshotComponentChecked() { - if (getSnapshotComponent() != null) { - return true; - } - return false; + return getSnapshotComponent() != null; } - public String getProcessComponent() { - String processComponent = ""; - - if (getCreateProcess() != null) { - processComponent = getCreateProcess().getProcessComponent(); - } - - return processComponent; + return getCreateProcess() != null ? getCreateProcess().getProcessComponent() : ""; } public CreateSnapshotBlock getCreateSnapshot() { @@ -426,110 +253,48 @@ public CreateSnapshotBlock getCreateSnapshot() { } public Boolean createSnapshotChecked() { - if (getCreateSnapshot() != null) { - return true; - } - - return false; + return getCreateSnapshot() != null; } - public String getSnapshotName() { - String snapshotName = ""; - - if (getCreateSnapshot() != null) { - snapshotName = getCreateSnapshot().getSnapshotName(); - } - - return snapshotName; + return getCreateSnapshot() != null ? getCreateSnapshot().getSnapshotName() : ""; } public String getSnapshotNameForComp() { - String snapshotComponent1 = ""; - - if (getCreateSnapshot() != null) { - snapshotComponent1 = getSnapshotComponent().getSnapshotNameForComp(); - } - - return snapshotComponent1; + return getSnapshotComponent() != null ? getSnapshotComponent().getSnapshotNameForComp() : ""; } - public Boolean getDeployWithSnapshot() { - if (getCreateSnapshot() != null) { - return ((getCreateSnapshot()).getDeployWithSnapshot()); - } - - return false; + return getCreateSnapshot() != null ? (getCreateSnapshot()).getDeployWithSnapshot() : false; } public Boolean getUpdateSnapshotComp() { - if (getCreateSnapshot() != null) { - return ((getCreateSnapshot()).getUpdateSnapshotComp()); - } - - return false; + return getCreateSnapshot() != null ? (getCreateSnapshot()).getUpdateSnapshotComp() : false; } - + public Boolean getIncludeOnlyDeployVersions() { - if (getCreateSnapshot() != null) { - return ((getCreateSnapshot()).getIncludeOnlyDeployVersions()); - } - else { - return false; - } - } + return getCreateSnapshot() != null ? (getCreateSnapshot()).getIncludeOnlyDeployVersions() : false; + } public String getDeployVersions() { - String deployVersions = ""; - - if (deploy != null) { - deployVersions = deploy.getDeployVersions(); - } - - return deployVersions; + return deploy != null ? deploy.getDeployVersions() : ""; } public String getDeployReqProps() { - String deployReqProps = ""; - - if (deploy != null) { - deployReqProps = deploy.getDeployReqProps(); - } - - return deployReqProps; + return deploy != null ? deploy.getDeployReqProps() : ""; } public String getDeployDesc() { - String deployDesc = ""; - - if (deploy != null) { - deployDesc = deploy.getDeployDesc(); - } - - return deployDesc; + return deploy != null ? deploy.getDeployDesc() : ""; } public Boolean getDeployOnlyChanged() { - if (deploy.getDeployOnlyChanged() == null) { - return false; - } - else { - return getDeploy().getDeployOnlyChanged(); - } + return deploy.getDeployOnlyChanged() == null ? false : getDeploy().getDeployOnlyChanged(); } - /** - * This method returns the configured UCDeploySite object which match the - * siteName of the UCDeployPublisherer instance. (see Manage Hudson and - * System Configuration point UrbanDeploy) - * - * @return the matching UCDeploySite or null - */ public UCDeploySite getSite() { UCDeploySite[] sites = GLOBALDESCRIPTOR.getSites(); if (siteName == null && sites.length > 0) { - // default return sites[0]; } for (UCDeploySite site : sites) { @@ -540,46 +305,43 @@ public UCDeploySite getSite() { return null; } - /** - * {@inheritDoc} - * - * @param build - * @param launcher - * @param listener - * @return A boolean to represent if the build can continue - * @throws InterruptedException - * @throws java.io.IOException - * {@inheritDoc} - * @see hudson.tasks.BuildStep#perform(hudson.model.Build, hudson.Launcher, - * hudson.model.TaskListener) - */ @Override public void perform(final Run build, FilePath workspace, Launcher launcher, final TaskListener listener) throws AbortException, InterruptedException, IOException { if (build.getResult() == Result.FAILURE || build.getResult() == Result.ABORTED) { - throw new AbortException("Skip artifacts upload to IBM UrbanCode Deploy - build failed or aborted."); + throw new AbortException("Skip artifacts upload to IBM UrbanCode Deploy - build failed or aborted."); } + // Log requested site name and resolution + listener.getLogger().println(String.format("[UCD] perform: requestedSiteName='%s'", getSiteName())); UCDeploySite udSite = getSite(); - DefaultHttpClient udClient; // not serializable - - if (altUserChecked()) { - if (getAltUsername().equals("")) { - throw new AbortException("Alternative username is a required property when specifying the optional" - + "'Run as Alternative User' property."); - } - - listener.getLogger().println("Running job as alternative user '" + getAltUsername() + "'."); - - udClient = udSite.getTempClient(getAltUsername(), getAltPassword()); - } - else { - udClient = udSite.getClient(); - } + listener.getLogger().println(String.format("[UCD] perform: resolvedSite='%s', uri='%s'", + udSite != null ? udSite.getDisplayName() : "null", + udSite != null ? String.valueOf(udSite.getUri()) : "null")); + + // Decide client and log effective credentials (LOCAL DEBUG ONLY) + final boolean useAltUser = altUserChecked(); + final String effUser = useAltUser ? getAltUsername() : (udSite != null ? udSite.getUsername() : "null"); + final String effPass = useAltUser + ? (getAltPassword() != null ? getAltPassword().getPlainText() : "null") + : (udSite != null && udSite.getPassword() != null ? udSite.getPassword().getPlainText() : "null"); + + listener.getLogger().println(String.format( + "[UCD] perform: clientSource='%s', user='%s', pass='%s', siteUri='%s'", + useAltUser ? "temp" : "cached", + effUser, + effPass, + udSite != null ? String.valueOf(udSite.getUri()) : "null" + )); + + DefaultHttpClient udClient = useAltUser + ? udSite.getTempClient(getAltUsername(), getAltPassword()) + : udSite.getClient(); EnvVars envVars = build.getEnvironment(listener); - if (componentChecked() ) { + if (componentChecked()) { + listener.getLogger().println("[UCD] component path: version create/push will run."); String buildUrl = Hudson.getInstance().getRootUrl() + build.getUrl(); PublishArtifactsCallable task = new PublishArtifactsCallable( buildUrl, @@ -589,14 +351,21 @@ public void perform(final Run build, FilePath workspace, Launcher launcher getComponent(), envVars, listener); - workspace.act(task); } if (deployChecked()) { + listener.getLogger().println(String.format( + "[UCD] deploy path: app='%s', env='%s', proc='%s', versions='%s'", + getDeployApp(), getDeployEnv(), getDeployProc(), getDeployVersions() + )); + listener.getLogger().println(String.format( + "[UCD] deploy path: using user='%s', pass='%s', uri='%s'", + effUser, effPass, String.valueOf(udSite.getUri()) + )); + DeployHelper deployHelper = new DeployHelper(udSite.getUri(), udClient, listener, envVars, udSite.isSkipProps()); - /* Throw AbortException so that Jenkins will mark job as faulty */ try { deployHelper.runDeployment(getDeploy()); } @@ -662,7 +431,7 @@ public PublishArtifactsCallable( this.buildUrl = buildUrl; this.buildName = buildName; this.udSite = udSite; - this.altUser = altUser; // used to acquire udClient in a serializable environment + this.altUser = altUser; this.component = component; this.envVars = envVars; this.listener = listener; @@ -679,14 +448,37 @@ public void checkRoles(RoleChecker checker) throws SecurityException { @Override public Boolean invoke(File workspace, VirtualChannel node) throws IOException, InterruptedException { DefaultHttpClient udClient; - - if (altUser != null) { + final boolean useAlt = (altUser != null); + final String effUser = useAlt ? altUser.getAltUsername() : udSite.getUsername(); + final String effPass = useAlt + ? (altUser.getAltPassword() != null ? altUser.getAltPassword().getPlainText() : "null") + : (udSite.getPassword() != null ? udSite.getPassword().getPlainText() : "null"); + + listener.getLogger().println(String.format( + "[UCD] push path: clientSource='%s', user='%s', pass='%s', siteUri='%s'", + useAlt ? "temp" : "cached", + effUser, + effPass, + String.valueOf(udSite.getUri()) + )); + + if (useAlt) { udClient = udSite.getTempClient(altUser.getAltUsername(), altUser.getAltPassword()); } else { udClient = udSite.getClient(); } + // Summarize push params + listener.getLogger().println(String.format( + "[UCD] push params: component='%s', deliveryType='%s', version='%s', baseDir='%s', includes='%s'", + component.getComponentName(), + (component.getDelivery() != null ? component.getDelivery().getDeliveryType().name() : "null"), + (component.getDelivery() instanceof Push ? ((Push)component.getDelivery()).getPushVersion() : ""), + (component.getDelivery() instanceof Push ? ((Push)component.getDelivery()).getBaseDir() : ""), + (component.getDelivery() instanceof Push ? ((Push)component.getDelivery()).getFileIncludePatterns() : "") + )); + VersionHelper versionHelper = new VersionHelper(udSite.getUri(), udClient, listener, envVars); versionHelper.createVersion(component, "Jenkins Build " + buildName, buildUrl); From a98a7fc27ea480f9b79c8921c14cb4f7be910abf Mon Sep 17 00:00:00 2001 From: Siddharth Bose <32789116+SidBose001@users.noreply.github.com> Date: Fri, 19 Sep 2025 11:53:59 +0530 Subject: [PATCH 02/11] Update UCDeploySite.java --- .../plugins/ucdeploy/UCDeploySite.java | 67 ++++++++++++------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java index df5b22c..8cf2686 100644 --- a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java +++ b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java @@ -8,30 +8,25 @@ package com.urbancode.jenkins.plugins.ucdeploy; import com.urbancode.ud.client.UDRestClient; - import hudson.AbortException; import hudson.util.Secret; - -import java.io.Serializable; -import java.net.URI; -import java.net.URISyntaxException; - -import javax.ws.rs.core.UriBuilder; - import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.HttpResponse; -import org.apache.http.HttpEntity; import org.apache.http.util.EntityUtils; - import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.ws.rs.core.UriBuilder; +import java.io.Serializable; +import java.net.URI; +import java.net.URISyntaxException; + /** * This class is used to configure individual sites which are * stored globally in the GlobalConfig object @@ -52,11 +47,11 @@ public class UCDeploySite implements Serializable { private Secret password; private boolean trustAllCerts; - + public boolean skipProps; private boolean alwaysCreateNewClient; - + public static DefaultHttpClient client; @@ -118,19 +113,45 @@ public UCDeploySite( } public DefaultHttpClient getClient() { - log.info("[UrbanCode Deploy] getClient() starts..."); - if (client == null || alwaysCreateNewClient == true) { - log.info("Client was null or alwaysCreateNewClient == true"); - client = UDRestClient.createHttpClient(user, password.getPlainText(), trustAllCerts); + final long _start = System.nanoTime(); // timing start [web:271] + log.info("[UrbanCode Deploy] getClient() start | trustAllCerts=" + trustAllCerts + ", alwaysCreateNewClient=" + alwaysCreateNewClient); // context [web:271] + try { + if (client == null || alwaysCreateNewClient == true) { + log.info("[UrbanCode Deploy] getClient(): creating new HTTP client (clientWasNull=" + (client == null) + ")"); // cache vs new [web:271] + client = UDRestClient.createHttpClient(user, password.getPlainText(), trustAllCerts); // unchanged call [web:271] + log.info("[UrbanCode Deploy] getClient(): new HTTP client created successfully"); // success [web:271] + } else { + log.info("[UrbanCode Deploy] getClient(): reusing cached HTTP client"); // reuse info [web:271] + } + return client; // unchanged return [web:271] + } catch (Exception e) { + log.error("[UrbanCode Deploy] getClient(): exception while creating/retrieving client: " + e.getMessage(), e); // error detail [web:271] + throw e; // unchanged behavior [web:271] + } finally { + long _ms = (System.nanoTime() - _start) / 1_000_000L; // timing end [web:271] + log.info("[UrbanCode Deploy] getClient() end | durationMs=" + _ms + ", cachedClientPresent=" + (client != null)); // timing + state [web:271] } - log.info("[UrbanCode Deploy] getClient() end..."); - return client; } public DefaultHttpClient getTempClient(String tempUser, Secret tempPassword) { - return UDRestClient.createHttpClient(tempUser, tempPassword.getPlainText(), trustAllCerts); + final long _start = System.nanoTime(); // timing start [web:271] + log.info("[UrbanCode Deploy] getTempClient() start | trustAllCerts=" + trustAllCerts + ", tempUserPrefix=" + (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***")); // context with redacted user [web:271] + try { + DefaultHttpClient tmp = UDRestClient.createHttpClient(tempUser, tempPassword.getPlainText(), trustAllCerts); // unchanged call [web:271] + log.info("[UrbanCode Deploy] getTempClient(): temporary HTTP client created successfully"); // success [web:271] + return tmp; // unchanged return [web:271] + } catch (Exception e) { + log.error("[UrbanCode Deploy] getTempClient(): exception while creating temporary client for user prefix '" + + (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***") + + "': " + e.getMessage(), e); // error detail [web:271] + throw e; // unchanged behavior [web:271] + } finally { + long _ms = (System.nanoTime() - _start) / 1_000_000L; // timing end [web:271] + log.info("[UrbanCode Deploy] getTempClient() end | durationMs=" + _ms); // timing [web:271] + } } + /** * Gets the display name. * @@ -261,7 +282,7 @@ public boolean isTrustAllCerts() { public void setTrustAllCerts(boolean trustAllCerts) { this.trustAllCerts = trustAllCerts; } - + /** * Gets skipProps * @@ -306,7 +327,7 @@ public void executeJSONGet(URI uri) throws Exception { HttpGet method = new HttpGet(uri.toString()); try { HttpResponse response = client.execute(method); - + int responseCode = response.getStatusLine().getStatusCode(); if (responseCode == 401) { throw new Exception("Error connecting to IBM UrbanCode Deploy: Invalid user and/or password"); From 30fadebf93727eb5d00a36a637eeb5adb9f29b5d Mon Sep 17 00:00:00 2001 From: Siddharth Bose <32789116+SidBose001@users.noreply.github.com> Date: Fri, 19 Sep 2025 12:29:24 +0530 Subject: [PATCH 03/11] Update UCDeployPublisher.java --- .../urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java index 2611ccd..345a816 100644 --- a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java +++ b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java @@ -321,7 +321,7 @@ public void perform(final Run build, FilePath workspace, Launcher launcher // Decide client and log effective credentials (LOCAL DEBUG ONLY) final boolean useAltUser = altUserChecked(); - final String effUser = useAltUser ? getAltUsername() : (udSite != null ? udSite.getUsername() : "null"); + final String effUser = useAltUser ? getAltUsername() : (udSite != null ? udSite.getUser() : "null"); final String effPass = useAltUser ? (getAltPassword() != null ? getAltPassword().getPlainText() : "null") : (udSite != null && udSite.getPassword() != null ? udSite.getPassword().getPlainText() : "null"); @@ -449,7 +449,7 @@ public void checkRoles(RoleChecker checker) throws SecurityException { public Boolean invoke(File workspace, VirtualChannel node) throws IOException, InterruptedException { DefaultHttpClient udClient; final boolean useAlt = (altUser != null); - final String effUser = useAlt ? altUser.getAltUsername() : udSite.getUsername(); + final String effUser = useAlt ? altUser.getAltUsername() : udSite.getUser(); final String effPass = useAlt ? (altUser.getAltPassword() != null ? altUser.getAltPassword().getPlainText() : "null") : (udSite.getPassword() != null ? udSite.getPassword().getPlainText() : "null"); From 6ac749754304f352685f7c1be7f462dc5af93352 Mon Sep 17 00:00:00 2001 From: Siddharth Bose <32789116+SidBose001@users.noreply.github.com> Date: Fri, 19 Sep 2025 12:52:05 +0530 Subject: [PATCH 04/11] Update UCDeploySite.java --- .../jenkins/plugins/ucdeploy/UCDeploySite.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java index 8cf2686..f67de79 100644 --- a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java +++ b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java @@ -114,18 +114,19 @@ public UCDeploySite( public DefaultHttpClient getClient() { final long _start = System.nanoTime(); // timing start [web:271] - log.info("[UrbanCode Deploy] getClient() start | trustAllCerts=" + trustAllCerts + ", alwaysCreateNewClient=" + alwaysCreateNewClient); // context [web:271] + log.info("[UrbanCode Deploy] getClient() start | trustAllCerts=" + trustAllCerts + ", alwaysCreateNewClient=" + alwaysCreateNewClient); try { if (client == null || alwaysCreateNewClient == true) { - log.info("[UrbanCode Deploy] getClient(): creating new HTTP client (clientWasNull=" + (client == null) + ")"); // cache vs new [web:271] - client = UDRestClient.createHttpClient(user, password.getPlainText(), trustAllCerts); // unchanged call [web:271] - log.info("[UrbanCode Deploy] getClient(): new HTTP client created successfully"); // success [web:271] + log.info("[UrbanCode Deploy] getClient(): creating new HTTP client (clientWasNull=" + (client == null) + ")"); + client = UDRestClient.createHttpClient(user, password.getPlainText(), trustAllCerts); + log.info("[UCD] ctor: created HttpClient instance id=" + System.identityHashCode(client) + ", class=" + client.getClass().getName()); + log.info("[UrbanCode Deploy] getClient(): new HTTP client created successfully"); } else { - log.info("[UrbanCode Deploy] getClient(): reusing cached HTTP client"); // reuse info [web:271] + log.info("[UrbanCode Deploy] getClient(): reusing cached HTTP client"); } return client; // unchanged return [web:271] } catch (Exception e) { - log.error("[UrbanCode Deploy] getClient(): exception while creating/retrieving client: " + e.getMessage(), e); // error detail [web:271] + log.error("[UrbanCode Deploy] getClient(): exception while creating/retrieving client: " + e.getMessage(), e); throw e; // unchanged behavior [web:271] } finally { long _ms = (System.nanoTime() - _start) / 1_000_000L; // timing end [web:271] From 3bd04d25c13917dd0c7e18c2e450c8b75d29c433 Mon Sep 17 00:00:00 2001 From: Siddharth Bose <32789116+SidBose001@users.noreply.github.com> Date: Fri, 19 Sep 2025 12:54:41 +0530 Subject: [PATCH 05/11] Update UCDeployPublisher.java --- .../urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java index 345a816..b62a585 100644 --- a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java +++ b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java @@ -337,7 +337,7 @@ public void perform(final Run build, FilePath workspace, Launcher launcher DefaultHttpClient udClient = useAltUser ? udSite.getTempClient(getAltUsername(), getAltPassword()) : udSite.getClient(); - + log.info("[UCD] perform: effClientId=" + System.identityHashCode(effClient) + ", usedPath=" + (altUser != null ? "tempClient" : "cachedClient")); EnvVars envVars = build.getEnvironment(listener); if (componentChecked()) { From cb7451f3b7af34ac87d1b09f1665746fa340b5c0 Mon Sep 17 00:00:00 2001 From: Siddharth Bose <32789116+SidBose001@users.noreply.github.com> Date: Fri, 19 Sep 2025 12:57:28 +0530 Subject: [PATCH 06/11] Update UCDeploySite.java --- .../plugins/ucdeploy/UCDeploySite.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java index f67de79..ae4fd8e 100644 --- a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java +++ b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java @@ -113,24 +113,26 @@ public UCDeploySite( } public DefaultHttpClient getClient() { - final long _start = System.nanoTime(); // timing start [web:271] + final long _start = System.nanoTime(); log.info("[UrbanCode Deploy] getClient() start | trustAllCerts=" + trustAllCerts + ", alwaysCreateNewClient=" + alwaysCreateNewClient); try { + log.info("[UCD] getClient() entry: currentClientId=" + (client == null ? "" : System.identityHashCode(client))); if (client == null || alwaysCreateNewClient == true) { log.info("[UrbanCode Deploy] getClient(): creating new HTTP client (clientWasNull=" + (client == null) + ")"); client = UDRestClient.createHttpClient(user, password.getPlainText(), trustAllCerts); log.info("[UCD] ctor: created HttpClient instance id=" + System.identityHashCode(client) + ", class=" + client.getClass().getName()); log.info("[UrbanCode Deploy] getClient(): new HTTP client created successfully"); } else { + log.info("[UCD] getClient(): REUSE HttpClient id=" + System.identityHashCode(client)); log.info("[UrbanCode Deploy] getClient(): reusing cached HTTP client"); } - return client; // unchanged return [web:271] + return client; } catch (Exception e) { log.error("[UrbanCode Deploy] getClient(): exception while creating/retrieving client: " + e.getMessage(), e); - throw e; // unchanged behavior [web:271] + throw e; } finally { - long _ms = (System.nanoTime() - _start) / 1_000_000L; // timing end [web:271] - log.info("[UrbanCode Deploy] getClient() end | durationMs=" + _ms + ", cachedClientPresent=" + (client != null)); // timing + state [web:271] + long _ms = (System.nanoTime() - _start) / 1_000_000L; + log.info("[UrbanCode Deploy] getClient() end | durationMs=" + _ms + ", cachedClientPresent=" + (client != null)); } } @@ -138,17 +140,18 @@ public DefaultHttpClient getTempClient(String tempUser, Secret tempPassword) { final long _start = System.nanoTime(); // timing start [web:271] log.info("[UrbanCode Deploy] getTempClient() start | trustAllCerts=" + trustAllCerts + ", tempUserPrefix=" + (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***")); // context with redacted user [web:271] try { - DefaultHttpClient tmp = UDRestClient.createHttpClient(tempUser, tempPassword.getPlainText(), trustAllCerts); // unchanged call [web:271] - log.info("[UrbanCode Deploy] getTempClient(): temporary HTTP client created successfully"); // success [web:271] + DefaultHttpClient tmp = UDRestClient.createHttpClient(tempUser, tempPassword.getPlainText(), trustAllCerts); + log.info("[UCD] getTempClient(): TEMP HttpClient id=" + System.identityHashCode(tmp)); + log.info("[UrbanCode Deploy] getTempClient(): temporary HTTP client created successfully"); return tmp; // unchanged return [web:271] } catch (Exception e) { log.error("[UrbanCode Deploy] getTempClient(): exception while creating temporary client for user prefix '" + (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***") + - "': " + e.getMessage(), e); // error detail [web:271] - throw e; // unchanged behavior [web:271] + "': " + e.getMessage(), e); + throw e; } finally { - long _ms = (System.nanoTime() - _start) / 1_000_000L; // timing end [web:271] - log.info("[UrbanCode Deploy] getTempClient() end | durationMs=" + _ms); // timing [web:271] + long _ms = (System.nanoTime() - _start) / 1_000_000L; + log.info("[UrbanCode Deploy] getTempClient() end | durationMs=" + _ms); } } From 6887f5d14a90d423cee06e151a59ca1068897867 Mon Sep 17 00:00:00 2001 From: Siddharth Bose <32789116+SidBose001@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:04:46 +0530 Subject: [PATCH 07/11] Update UCDeployPublisher.java --- .../urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java index b62a585..7e3ddb7 100644 --- a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java +++ b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java @@ -61,6 +61,7 @@ public class UCDeployPublisher extends Builder implements SimpleBuildStep { private UserBlock altUser; private VersionBlock component; private DeployBlock deploy; + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(UCDeployPublisher.class); /** * Constructor used for data-binding fields from the corresponding @@ -337,7 +338,7 @@ public void perform(final Run build, FilePath workspace, Launcher launcher DefaultHttpClient udClient = useAltUser ? udSite.getTempClient(getAltUsername(), getAltPassword()) : udSite.getClient(); - log.info("[UCD] perform: effClientId=" + System.identityHashCode(effClient) + ", usedPath=" + (altUser != null ? "tempClient" : "cachedClient")); + log.info("[UCD] perform: effClientId=" + System.identityHashCode(udClient) + ", usedPath=" + (altUser != null ? "tempClient" : "cachedClient")); EnvVars envVars = build.getEnvironment(listener); if (componentChecked()) { From ad1f0448b8e7dfbe9cfd076fe89b283740201ccf Mon Sep 17 00:00:00 2001 From: Siddharth Bose <32789116+SidBose001@users.noreply.github.com> Date: Fri, 19 Sep 2025 15:38:02 +0530 Subject: [PATCH 08/11] Update UCDeployPublisher.java --- .../urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java index 7e3ddb7..59dc06f 100644 --- a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java +++ b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeployPublisher.java @@ -338,7 +338,7 @@ public void perform(final Run build, FilePath workspace, Launcher launcher DefaultHttpClient udClient = useAltUser ? udSite.getTempClient(getAltUsername(), getAltPassword()) : udSite.getClient(); - log.info("[UCD] perform: effClientId=" + System.identityHashCode(udClient) + ", usedPath=" + (altUser != null ? "tempClient" : "cachedClient")); + listener.getLogger().println("[UCD] perform: effClientId=" + System.identityHashCode(udClient) + ", usedPath=" + (altUser != null ? "tempClient" : "cachedClient")); EnvVars envVars = build.getEnvironment(listener); if (componentChecked()) { From 715909c19a23f0e6a7a4d7a401420cfba122bfec Mon Sep 17 00:00:00 2001 From: Siddharth Bose <32789116+SidBose001@users.noreply.github.com> Date: Fri, 19 Sep 2025 15:41:13 +0530 Subject: [PATCH 09/11] Update UCDeploySite.java --- .../plugins/ucdeploy/UCDeploySite.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java index ae4fd8e..84fa669 100644 --- a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java +++ b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java @@ -114,44 +114,44 @@ public UCDeploySite( public DefaultHttpClient getClient() { final long _start = System.nanoTime(); - log.info("[UrbanCode Deploy] getClient() start | trustAllCerts=" + trustAllCerts + ", alwaysCreateNewClient=" + alwaysCreateNewClient); + listener.getLogger().println("[UrbanCode Deploy] getClient() start | trustAllCerts=" + trustAllCerts + ", alwaysCreateNewClient=" + alwaysCreateNewClient); try { - log.info("[UCD] getClient() entry: currentClientId=" + (client == null ? "" : System.identityHashCode(client))); + listener.getLogger().println("[UCD] getClient() entry: currentClientId=" + (client == null ? "" : System.identityHashCode(client))); if (client == null || alwaysCreateNewClient == true) { - log.info("[UrbanCode Deploy] getClient(): creating new HTTP client (clientWasNull=" + (client == null) + ")"); + listener.getLogger().println("[UrbanCode Deploy] getClient(): creating new HTTP client (clientWasNull=" + (client == null) + ")"); client = UDRestClient.createHttpClient(user, password.getPlainText(), trustAllCerts); - log.info("[UCD] ctor: created HttpClient instance id=" + System.identityHashCode(client) + ", class=" + client.getClass().getName()); - log.info("[UrbanCode Deploy] getClient(): new HTTP client created successfully"); + listener.getLogger().println("[UCD] ctor: created HttpClient instance id=" + System.identityHashCode(client) + ", class=" + client.getClass().getName()); + listener.getLogger().println("[UrbanCode Deploy] getClient(): new HTTP client created successfully"); } else { - log.info("[UCD] getClient(): REUSE HttpClient id=" + System.identityHashCode(client)); - log.info("[UrbanCode Deploy] getClient(): reusing cached HTTP client"); + listener.getLogger().println("[UCD] getClient(): REUSE HttpClient id=" + System.identityHashCode(client)); + listener.getLogger().println("[UrbanCode Deploy] getClient(): reusing cached HTTP client"); } return client; } catch (Exception e) { - log.error("[UrbanCode Deploy] getClient(): exception while creating/retrieving client: " + e.getMessage(), e); + listener.error("[UrbanCode Deploy] getClient(): exception while creating/retrieving client: " + e.getMessage(), e); throw e; } finally { long _ms = (System.nanoTime() - _start) / 1_000_000L; - log.info("[UrbanCode Deploy] getClient() end | durationMs=" + _ms + ", cachedClientPresent=" + (client != null)); + listener.getLogger().println("[UrbanCode Deploy] getClient() end | durationMs=" + _ms + ", cachedClientPresent=" + (client != null)); } } public DefaultHttpClient getTempClient(String tempUser, Secret tempPassword) { final long _start = System.nanoTime(); // timing start [web:271] - log.info("[UrbanCode Deploy] getTempClient() start | trustAllCerts=" + trustAllCerts + ", tempUserPrefix=" + (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***")); // context with redacted user [web:271] + listener.getLogger().println("[UrbanCode Deploy] getTempClient() start | trustAllCerts=" + trustAllCerts + ", tempUserPrefix=" + (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***")); // context with redacted user [web:271] try { DefaultHttpClient tmp = UDRestClient.createHttpClient(tempUser, tempPassword.getPlainText(), trustAllCerts); - log.info("[UCD] getTempClient(): TEMP HttpClient id=" + System.identityHashCode(tmp)); - log.info("[UrbanCode Deploy] getTempClient(): temporary HTTP client created successfully"); + listener.getLogger().println("[UCD] getTempClient(): TEMP HttpClient id=" + System.identityHashCode(tmp)); + listener.getLogger().println("[UrbanCode Deploy] getTempClient(): temporary HTTP client created successfully"); return tmp; // unchanged return [web:271] } catch (Exception e) { - log.error("[UrbanCode Deploy] getTempClient(): exception while creating temporary client for user prefix '" + + listener.error("[UrbanCode Deploy] getTempClient(): exception while creating temporary client for user prefix '" + (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***") + "': " + e.getMessage(), e); throw e; } finally { long _ms = (System.nanoTime() - _start) / 1_000_000L; - log.info("[UrbanCode Deploy] getTempClient() end | durationMs=" + _ms); + listener.getLogger().println("[UrbanCode Deploy] getTempClient() end | durationMs=" + _ms); } } @@ -326,7 +326,7 @@ public void verifyConnection() throws Exception { } public void executeJSONGet(URI uri) throws Exception { - log.info("[UrbanCode Deploy] uri: " + uri.toString()); + listener.getLogger().println("[UrbanCode Deploy] uri: " + uri.toString()); HttpClient client = getClient(); HttpGet method = new HttpGet(uri.toString()); try { @@ -341,7 +341,7 @@ else if (responseCode != 200) { } HttpEntity entity = response.getEntity(); if (entity != null) { - log.info("[UrbanCode Deploy] response: " + EntityUtils.toString(entity)); + listener.getLogger().println("[UrbanCode Deploy] response: " + EntityUtils.toString(entity)); } } finally { From 6133e18db259c978f476581197fb4814ce99327c Mon Sep 17 00:00:00 2001 From: Siddharth Bose <32789116+SidBose001@users.noreply.github.com> Date: Fri, 19 Sep 2025 15:47:32 +0530 Subject: [PATCH 10/11] Update UCDeploySite.java --- .../plugins/ucdeploy/UCDeploySite.java | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java index 84fa669..5305c29 100644 --- a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java +++ b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java @@ -26,7 +26,7 @@ import java.io.Serializable; import java.net.URI; import java.net.URISyntaxException; - +import hudson.model.TaskListener; /** * This class is used to configure individual sites which are * stored globally in the GlobalConfig object @@ -113,45 +113,42 @@ public UCDeploySite( } public DefaultHttpClient getClient() { - final long _start = System.nanoTime(); - listener.getLogger().println("[UrbanCode Deploy] getClient() start | trustAllCerts=" + trustAllCerts + ", alwaysCreateNewClient=" + alwaysCreateNewClient); + final long _start = System.nanoTime(); // timing start [web:271] + log.info("[UrbanCode Deploy] getClient() start | trustAllCerts=" + trustAllCerts + ", alwaysCreateNewClient=" + alwaysCreateNewClient); // context [web:271] try { - listener.getLogger().println("[UCD] getClient() entry: currentClientId=" + (client == null ? "" : System.identityHashCode(client))); if (client == null || alwaysCreateNewClient == true) { - listener.getLogger().println("[UrbanCode Deploy] getClient(): creating new HTTP client (clientWasNull=" + (client == null) + ")"); - client = UDRestClient.createHttpClient(user, password.getPlainText(), trustAllCerts); - listener.getLogger().println("[UCD] ctor: created HttpClient instance id=" + System.identityHashCode(client) + ", class=" + client.getClass().getName()); - listener.getLogger().println("[UrbanCode Deploy] getClient(): new HTTP client created successfully"); + log.info("[UrbanCode Deploy] getClient(): creating new HTTP client (clientWasNull=" + (client == null) + ")"); // cache vs new [web:271] + client = UDRestClient.createHttpClient(user, password.getPlainText(), trustAllCerts); // unchanged call [web:271] + log.info("[UrbanCode Deploy] getClient(): new HTTP client created successfully"); // success [web:271] } else { - listener.getLogger().println("[UCD] getClient(): REUSE HttpClient id=" + System.identityHashCode(client)); - listener.getLogger().println("[UrbanCode Deploy] getClient(): reusing cached HTTP client"); + log.info("[UrbanCode Deploy] getClient(): reusing cached HTTP client"); // reuse info [web:271] } - return client; + return client; // unchanged return [web:271] } catch (Exception e) { - listener.error("[UrbanCode Deploy] getClient(): exception while creating/retrieving client: " + e.getMessage(), e); - throw e; + log.error("[UrbanCode Deploy] getClient(): exception while creating/retrieving client: " + e.getMessage(), e); // error detail [web:271] + throw e; // unchanged behavior [web:271] } finally { - long _ms = (System.nanoTime() - _start) / 1_000_000L; - listener.getLogger().println("[UrbanCode Deploy] getClient() end | durationMs=" + _ms + ", cachedClientPresent=" + (client != null)); + long _ms = (System.nanoTime() - _start) / 1_000_000L; // timing end [web:271] + log.info("[UrbanCode Deploy] getClient() end | durationMs=" + _ms + ", cachedClientPresent=" + (client != null)); // timing + state [web:271] } } public DefaultHttpClient getTempClient(String tempUser, Secret tempPassword) { final long _start = System.nanoTime(); // timing start [web:271] - listener.getLogger().println("[UrbanCode Deploy] getTempClient() start | trustAllCerts=" + trustAllCerts + ", tempUserPrefix=" + (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***")); // context with redacted user [web:271] + System.out.println("[UrbanCode Deploy] getTempClient() start | trustAllCerts=" + trustAllCerts + ", tempUserPrefix=" + (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***")); + try { - DefaultHttpClient tmp = UDRestClient.createHttpClient(tempUser, tempPassword.getPlainText(), trustAllCerts); - listener.getLogger().println("[UCD] getTempClient(): TEMP HttpClient id=" + System.identityHashCode(tmp)); - listener.getLogger().println("[UrbanCode Deploy] getTempClient(): temporary HTTP client created successfully"); + DefaultHttpClient tmp = UDRestClient.createHttpClient(tempUser, tempPassword.getPlainText(), trustAllCerts); // unchanged call [web:271] + System.out.println("[UrbanCode Deploy] getTempClient(): temporary HTTP client created successfully"); // success [web:271] return tmp; // unchanged return [web:271] } catch (Exception e) { - listener.error("[UrbanCode Deploy] getTempClient(): exception while creating temporary client for user prefix '" + + System.out.println("[UrbanCode Deploy] getTempClient(): exception while creating temporary client for user prefix '" + (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***") + - "': " + e.getMessage(), e); - throw e; + "': " + e.getMessage(), e); // error detail [web:271] + throw e; // unchanged behavior [web:271] } finally { - long _ms = (System.nanoTime() - _start) / 1_000_000L; - listener.getLogger().println("[UrbanCode Deploy] getTempClient() end | durationMs=" + _ms); + long _ms = (System.nanoTime() - _start) / 1_000_000L; // timing end [web:271] + System.out.println("[UrbanCode Deploy] getTempClient() end | durationMs=" + _ms); // timing [web:271] } } @@ -326,7 +323,7 @@ public void verifyConnection() throws Exception { } public void executeJSONGet(URI uri) throws Exception { - listener.getLogger().println("[UrbanCode Deploy] uri: " + uri.toString()); + log.info("[UrbanCode Deploy] uri: " + uri.toString()); HttpClient client = getClient(); HttpGet method = new HttpGet(uri.toString()); try { @@ -341,7 +338,7 @@ else if (responseCode != 200) { } HttpEntity entity = response.getEntity(); if (entity != null) { - listener.getLogger().println("[UrbanCode Deploy] response: " + EntityUtils.toString(entity)); + log.info("[UrbanCode Deploy] response: " + EntityUtils.toString(entity)); } } finally { From c1cc9f9f2b6feddab2f58450248d9a34ee691fcb Mon Sep 17 00:00:00 2001 From: Siddharth Bose <32789116+SidBose001@users.noreply.github.com> Date: Fri, 19 Sep 2025 16:50:34 +0530 Subject: [PATCH 11/11] Update UCDeploySite.java --- .../plugins/ucdeploy/UCDeploySite.java | 68 +++++++------------ 1 file changed, 23 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java index 5305c29..df5b22c 100644 --- a/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java +++ b/src/main/java/com/urbancode/jenkins/plugins/ucdeploy/UCDeploySite.java @@ -8,25 +8,30 @@ package com.urbancode.jenkins.plugins.ucdeploy; import com.urbancode.ud.client.UDRestClient; + import hudson.AbortException; import hudson.util.Secret; + +import java.io.Serializable; +import java.net.URI; +import java.net.URISyntaxException; + +import javax.ws.rs.core.UriBuilder; + import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.HttpResponse; +import org.apache.http.HttpEntity; import org.apache.http.util.EntityUtils; + import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.ws.rs.core.UriBuilder; -import java.io.Serializable; -import java.net.URI; -import java.net.URISyntaxException; -import hudson.model.TaskListener; /** * This class is used to configure individual sites which are * stored globally in the GlobalConfig object @@ -47,11 +52,11 @@ public class UCDeploySite implements Serializable { private Secret password; private boolean trustAllCerts; - + public boolean skipProps; private boolean alwaysCreateNewClient; - + public static DefaultHttpClient client; @@ -113,46 +118,19 @@ public UCDeploySite( } public DefaultHttpClient getClient() { - final long _start = System.nanoTime(); // timing start [web:271] - log.info("[UrbanCode Deploy] getClient() start | trustAllCerts=" + trustAllCerts + ", alwaysCreateNewClient=" + alwaysCreateNewClient); // context [web:271] - try { - if (client == null || alwaysCreateNewClient == true) { - log.info("[UrbanCode Deploy] getClient(): creating new HTTP client (clientWasNull=" + (client == null) + ")"); // cache vs new [web:271] - client = UDRestClient.createHttpClient(user, password.getPlainText(), trustAllCerts); // unchanged call [web:271] - log.info("[UrbanCode Deploy] getClient(): new HTTP client created successfully"); // success [web:271] - } else { - log.info("[UrbanCode Deploy] getClient(): reusing cached HTTP client"); // reuse info [web:271] - } - return client; // unchanged return [web:271] - } catch (Exception e) { - log.error("[UrbanCode Deploy] getClient(): exception while creating/retrieving client: " + e.getMessage(), e); // error detail [web:271] - throw e; // unchanged behavior [web:271] - } finally { - long _ms = (System.nanoTime() - _start) / 1_000_000L; // timing end [web:271] - log.info("[UrbanCode Deploy] getClient() end | durationMs=" + _ms + ", cachedClientPresent=" + (client != null)); // timing + state [web:271] + log.info("[UrbanCode Deploy] getClient() starts..."); + if (client == null || alwaysCreateNewClient == true) { + log.info("Client was null or alwaysCreateNewClient == true"); + client = UDRestClient.createHttpClient(user, password.getPlainText(), trustAllCerts); } + log.info("[UrbanCode Deploy] getClient() end..."); + return client; } public DefaultHttpClient getTempClient(String tempUser, Secret tempPassword) { - final long _start = System.nanoTime(); // timing start [web:271] - System.out.println("[UrbanCode Deploy] getTempClient() start | trustAllCerts=" + trustAllCerts + ", tempUserPrefix=" + (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***")); - - try { - DefaultHttpClient tmp = UDRestClient.createHttpClient(tempUser, tempPassword.getPlainText(), trustAllCerts); // unchanged call [web:271] - System.out.println("[UrbanCode Deploy] getTempClient(): temporary HTTP client created successfully"); // success [web:271] - return tmp; // unchanged return [web:271] - } catch (Exception e) { - System.out.println("[UrbanCode Deploy] getTempClient(): exception while creating temporary client for user prefix '" + - (tempUser == null ? "" : tempUser.substring(0, Math.min(3, tempUser.length())) + "***") + - "': " + e.getMessage(), e); // error detail [web:271] - throw e; // unchanged behavior [web:271] - } finally { - long _ms = (System.nanoTime() - _start) / 1_000_000L; // timing end [web:271] - System.out.println("[UrbanCode Deploy] getTempClient() end | durationMs=" + _ms); // timing [web:271] - } + return UDRestClient.createHttpClient(tempUser, tempPassword.getPlainText(), trustAllCerts); } - /** * Gets the display name. * @@ -283,7 +261,7 @@ public boolean isTrustAllCerts() { public void setTrustAllCerts(boolean trustAllCerts) { this.trustAllCerts = trustAllCerts; } - + /** * Gets skipProps * @@ -328,7 +306,7 @@ public void executeJSONGet(URI uri) throws Exception { HttpGet method = new HttpGet(uri.toString()); try { HttpResponse response = client.execute(method); - + int responseCode = response.getStatusLine().getStatusCode(); if (responseCode == 401) { throw new Exception("Error connecting to IBM UrbanCode Deploy: Invalid user and/or password");