package org.jenkinsci.plugins.p4_client; import hudson.FilePath.FileCallable; import hudson.remoting.VirtualChannel; import java.io.File; import java.io.IOException; import java.util.Map; import org.jenkinsci.plugins.p4_client.client.ConnectionHelper; import org.jenkinsci.plugins.p4_client.workspace.Workspace; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CheckoutTask implements FileCallable<Boolean> { private static final long serialVersionUID = 1L; private Logger logger = LoggerFactory.getLogger(CheckoutTask.class); private ConnectionHelper p4; private int change; private int review; private CheckoutStatus status = CheckoutStatus.HEAD; /** * Constructor * * @param config * - Server connection details * @param auth * - Server login details */ public CheckoutTask(String credentialID, Workspace config) { try { p4 = new ConnectionHelper(credentialID); p4.login(); p4.setClient(config); } catch (Exception e) { logger.error("Unable to connect."); e.printStackTrace(); } } /** * Invoke sync on build node (master or remote node). * * @return true if updated, false if no change. */ public Boolean invoke(File workspace, VirtualChannel channel) throws IOException { logger.info("P4:CheckoutTask sync..."); try { p4.tidyWorkspace(); switch (status) { case HEAD: p4.syncFiles(); break; case COMMITTED: p4.syncFiles(change); break; case SHELVED: p4.unshelveFiles(review); break; default: logger.error("P4:CheckoutTask unknown status: " + status); return false; } p4.disconnect(); } catch (Exception e) { logger.error("Unable to sync workspace."); e.printStackTrace(); return false; } return true; } /** * Takes the Build Variables set for the Jenkins Action and sets status, * change and review numbers. * * @param buildVariables */ public void setBuildVariables(Map<String, String> map) { if (map == null) { return; } if (map.containsKey("status")) { String value = map.get("status"); status = CheckoutStatus.parse(value); } if (map.containsKey("change")) { String value = map.get("change"); try { change = Integer.parseInt(value); } catch (NumberFormatException e) { change = 0; } } if (map.containsKey("review")) { String value = map.get("review"); try { review = Integer.parseInt(value); } catch (NumberFormatException e) { change = 0; } } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#15 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
#14 | 9371 | Paul Allen | Fix issue when label could be empty (called by Swarm or Review URL). | ||
#13 | 9115 | Paul Allen |
Initial implementation of workspace Cleanup and Sync options. - Includes 3 modes: Automatic Clean/Sync, Force Clean/Sync, Sync Only Automatic Clean/Sync Uses reconcile to clean up workspace and sync changes. Force Clean/Sync Force sync of all files (does not remove files yet...) Sync Only Normal sync with no cleanup TODO: - remove of files in Force Clean/Sync mode - Inline help - Update docs - Add unit/functional tests |
||
#12 | 9069 | Paul Allen |
Adding initial support for tagging Jenkins builds as Perforce Automatic Labels. Only implements TagAction (manual labels); TagNotifier and test cases TODO. |
||
#11 | 9055 | Paul Allen |
Label support. Build at a label using the pram 'label'. This includes adding the label to the ChangeEntry, building the change reports and Browser links to Swarm. (TPI-102) |
||
#10 | 8969 | Paul Allen |
Adds all contributing change-lists for the build to the change log (using p4 cstat). - Includes exception logging for server connection to the Jenkins console. |
||
#9 | 8940 | Paul Allen |
Major refactor for the ConnectionHelper class to simplify serialisation. Fixed remote Jenkins JNLP slave connection issue. ClientHelper now extends ConnectionHelper and takes on all methods that require a client workspace. P4StandardCredentials is sent to the remote node instead of Credentials ID due to an issue accessing the Credentials store over a remote connection. For simplicity Client ID (workspace name) is serialised instead of the Workspace object. |
||
#8 | 8926 | Paul Allen |
Bug fix when unshelving files with the Template workspace option. p4-java was unable to switch the worksapce view (without the -f flag) if there were files open. - Improved logging (as this error was hidden) - Added test case for this condition. |
||
#7 | 8924 | Paul Allen | Sync workspace to last change in workspace (not depot). | ||
#6 | 8915 | Paul Allen |
Support for ChangeLog and RepoBrowser. - Added RepoBrowser for Swarm (porting the others should be easy) - ChangeLog XML file now only stores the changelist number all other information is fetched from Perforce |
||
#5 | 8765 | Paul Allen | Update status to include SUBMITTED and sync to change. | ||
#4 | 8762 | Paul Allen |
Console Ouptut logging for SCM build steps. - Removed SLF4J and used old style logger (matching Jenkins) - Set Client Host filed to null, Jenkins sometimes gives an IP address. - Test p4java setps in SCM tasks for success(true/false) |
||
#3 | 8725 | Paul Allen |
Minor fixes: - Improved tidy workspace method - Fix for template clients - After an unshelf revert -k files - Minor bug in CheckoutTask - Clear callback urls to prevet reuse |
||
#2 | 8715 | Paul Allen |
#review-8716 [Basic Swarm-Jenkins cycle DONE] Support Job's build notification and then POST's the pass/fail call-back URLs to Swarm. |
||
#1 | 8694 | Paul Allen | Added support for unshelve and revert -w behaviour for builds. |