package org.jenkinsci.plugins.p4.client; import hudson.model.Item; import hudson.model.TaskListener; import org.jenkinsci.plugins.p4.workspace.ManualWorkspaceImpl; import org.jenkinsci.plugins.p4.workspace.Workspace; import org.jenkinsci.plugins.p4.workspace.WorkspaceSpec; import java.io.Closeable; import java.io.IOException; import java.util.HashMap; import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; public class TempClientHelper extends ClientHelper implements Closeable { private static final Logger LOGGER = Logger.getLogger(TempClientHelper.class.getName()); private final String clientUUID; public TempClientHelper(Item context, String credential, TaskListener listener, Workspace workspace) throws Exception { super(context, credential, listener); String oldName = workspace.getName(); this.clientUUID = "jenkinsTemp-" + UUID.randomUUID().toString(); workspace.setName(clientUUID); workspace.setExpand(new HashMap<String, String>()); // Update view with new name if(workspace instanceof ManualWorkspaceImpl) { ManualWorkspaceImpl manual = (ManualWorkspaceImpl) workspace; WorkspaceSpec spec = manual.getSpec(); String view = spec.getView(); view = view.replace(oldName, clientUUID); spec.setView(view); manual.setSpec(spec); } //clientLogin(clientUUID, workspace.getCharset()); setClient(workspace); } @Override public void close() throws IOException { try { deleteClient(clientUUID); } catch (Exception e) { LOGGER.log(Level.INFO, "Unable to remove temporary client: " + clientUUID); } disconnect(); } public String getClientUUID() { return clientUUID; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 23690 | Paul Allen | Cleanup P4Task: use Closable and not a call to p4.disconnect() | ||
#1 | 23685 | Paul Allen | Copy main -> dev | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/client/TempClientHelper.java | |||||
#2 | 23373 | Paul Allen |
Lightweight checkout support. Implementation for scm-api classes SCMFile and SCMFileSystem, allowing Jenkins to navigate Perforce within the scope of a workspace view. Lightweight checkout uses a tempoary Perforce workspace to naviagete and fetch the files. The client name and client view mapping will be modified from a template name e.g. jenkins-${NODE_NAME}-${JOB_NAME} to the tempoary name jenkinsTemp-UUID. Alternativly if a user as used ${P4_CLIENT} in the client mapping this will remain unchanged and will be get expanded during the job run. JENKINS-45999 JENKINS-46269 |
||
#1 | 23324 | Paul Allen | Use short lived temporary client when scanning MultiBranch. |