Package org.jenkinsci.plugins.p4.client
Class ClientHelper
- java.lang.Object
-
- org.jenkinsci.plugins.p4.client.CredentialsHelper
-
- org.jenkinsci.plugins.p4.client.SessionHelper
-
- org.jenkinsci.plugins.p4.client.ConnectionHelper
-
- org.jenkinsci.plugins.p4.client.ClientHelper
-
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
TempClientHelper
public class ClientHelper extends ConnectionHelper
-
-
Constructor Summary
Constructors Modifier Constructor Description ClientHelper(ItemGroup context, String credential, TaskListener listener, Workspace workspace)
protected
ClientHelper(Item context, String credential, TaskListener listener)
ClientHelper(Item context, String credential, TaskListener listener, Workspace workspace)
ClientHelper(P4BaseCredentials credential, TaskListener listener, Workspace workspace)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
buildChange(Publish publish)
protected void
clientLogin(Workspace workspace)
int
findPendingChangelistIDByDesc(String desc, String client)
com.perforce.p4java.impl.generic.core.Changelist
getChange(long id)
Gets the Changelist (p4 describe -s); shouldn't need a client, but p4-java throws an exception if one is not set.com.perforce.p4java.client.IClient
getClient()
long
getClientHead()
Get the change number for the last change within the scope of the workspace view.long
getClientHead(P4Ref from, P4Ref to)
Get the change number for the last change within the scope of the workspace view up to the specified revisioncom.perforce.p4java.impl.generic.client.ClientView
getClientView()
List<com.perforce.p4java.core.IChangelistSummary>
getPendingChangelists(boolean includeLongDescription, String clientName)
boolean
isClientValid(Workspace workspace)
List<P4Ref>
listChanges()
Show all changes within the scope of the client.List<P4Ref>
listChanges(List<P4Ref> fromRefs, P4Ref to)
Show all changes within the scope of the client, between the 'from' and 'to' change limits.List<P4Ref>
listChanges(P4Ref from)
Show all changes within the scope of the client, from the 'from' change limits.List<P4Ref>
listHaveChanges(List<P4Ref> fromRefs)
Fetches a list of changes needed to update the workspace to head.List<P4Ref>
listHaveChanges(List<P4Ref> fromRefs, P4Ref changeLimit)
Fetches a list of changes needed to update the workspace to the specified limit.List<com.perforce.p4java.core.IRepo>
listRepos()
List of Graph Repos within the client's viewString
publishChange(Publish publish)
void
resolveFiles(String mode)
Resolve files in workspace with the specified option.void
revertAllFiles(boolean virtual)
void
syncFiles(P4Ref buildChange, Populate populate)
Sync files to workspace at the specified change/label.void
tidyWorkspace(Populate populate)
Cleans up the Perforce workspace after a previous build.void
unshelveFiles(long review)
Unshelve review into workspace.void
versionFile(String file, Publish publish, int ChangelistID, boolean submit)
String
where(String localFile)
-
Methods inherited from class org.jenkinsci.plugins.p4.client.ConnectionHelper
buildRevisionLimit, close, counterToChange, deleteClient, getChangeFiles, getChangeSummary, getCommitFiles, getCounter, getDirs, getEmail, getGraphCommit, getGraphHead, getHead, getHeadLimit, getJobs, getLabel, getLabelFiles, getLowestHead, getMaxChangeLimit, getShelvedFiles, getStreams, getSwarm, hasFile, isClient, isCounter, isLabel, labelToChange, listAllRepos, listCommits, listRepos, setLabel
-
Methods inherited from class org.jenkinsci.plugins.p4.client.SessionHelper
abort, checkVersion, disconnect, getConnection, getP4SCM, getTicket, getTrust, getValidate, hasAborted, invalidateSession, invalidateSession, isConnected, isUnicode, login, logout
-
Methods inherited from class org.jenkinsci.plugins.p4.client.CredentialsHelper
findCredential, findCredential, findCredential, findCredential, getAuthorisationConfig, getCredential, getListener, getPort, getRetry, getTick, getUser, log
-
-
-
-
Constructor Detail
-
ClientHelper
public ClientHelper(ItemGroup context, String credential, TaskListener listener, Workspace workspace) throws IOException
- Throws:
IOException
-
ClientHelper
public ClientHelper(Item context, String credential, TaskListener listener, Workspace workspace) throws IOException
- Throws:
IOException
-
ClientHelper
public ClientHelper(P4BaseCredentials credential, TaskListener listener, Workspace workspace) throws IOException
- Throws:
IOException
-
ClientHelper
protected ClientHelper(Item context, String credential, TaskListener listener) throws IOException
- Throws:
IOException
-
-
Method Detail
-
clientLogin
protected void clientLogin(Workspace workspace) throws AbortException
- Throws:
AbortException
-
syncFiles
public void syncFiles(P4Ref buildChange, Populate populate) throws Exception
Sync files to workspace at the specified change/label.- Parameters:
buildChange
- Change to sync frompopulate
- Populate strategy- Throws:
Exception
- push up stack
-
tidyWorkspace
public void tidyWorkspace(Populate populate) throws Exception
Cleans up the Perforce workspace after a previous build. Removes all pending and abandoned files (equivalent to 'p4 revert -w').- Parameters:
populate
- Jelly populate options- Throws:
Exception
- push up stack
-
versionFile
public void versionFile(String file, Publish publish, int ChangelistID, boolean submit) throws Exception
- Throws:
Exception
-
unshelveFiles
public void unshelveFiles(long review) throws Exception
Unshelve review into workspace. Workspace is sync'ed to head first then review unshelved.- Parameters:
review
- Review number (perhaps long?)- Throws:
Exception
- push up stack
-
resolveFiles
public void resolveFiles(String mode) throws Exception
Resolve files in workspace with the specified option.- Parameters:
mode
- Resolve mode- Throws:
Exception
- push up stack
-
getChange
public com.perforce.p4java.impl.generic.core.Changelist getChange(long id) throws Exception
Gets the Changelist (p4 describe -s); shouldn't need a client, but p4-java throws an exception if one is not set.- Parameters:
id
- Change number (long perhaps)- Returns:
- Perforce Changelist
- Throws:
Exception
- push up stack
-
getClientHead
public long getClientHead(P4Ref from, P4Ref to) throws Exception
Get the change number for the last change within the scope of the workspace view up to the specified revision- Parameters:
from
- From revision (change or label)to
- To revision (change or label)- Returns:
- Perforce change
- Throws:
Exception
- push up stack
-
getClientHead
public long getClientHead() throws Exception
Get the change number for the last change within the scope of the workspace view. If there are no recent changes use the latest change.- Returns:
- Perforce change
- Throws:
Exception
- push up stack
-
getPendingChangelists
public List<com.perforce.p4java.core.IChangelistSummary> getPendingChangelists(boolean includeLongDescription, String clientName) throws Exception
- Throws:
Exception
-
findPendingChangelistIDByDesc
public int findPendingChangelistIDByDesc(String desc, String client) throws Exception
- Throws:
Exception
-
listRepos
public List<com.perforce.p4java.core.IRepo> listRepos()
List of Graph Repos within the client's view- Returns:
- A list of Graph Repos, empty list on error.
-
listChanges
public List<P4Ref> listChanges(List<P4Ref> fromRefs, P4Ref to) throws Exception
Show all changes within the scope of the client, between the 'from' and 'to' change limits.- Parameters:
fromRefs
- list of from revisions (change or label)to
- To revision (change or label)- Returns:
- List of changes
- Throws:
Exception
- push up stack
-
listChanges
public List<P4Ref> listChanges(P4Ref from) throws Exception
Show all changes within the scope of the client, from the 'from' change limits.- Parameters:
from
- From revision (change or label)- Returns:
- List of changes
- Throws:
Exception
- push up stack
-
listChanges
public List<P4Ref> listChanges() throws Exception
Show all changes within the scope of the client.- Returns:
- List of changes
- Throws:
Exception
- push up stack
-
listHaveChanges
public List<P4Ref> listHaveChanges(List<P4Ref> fromRefs) throws Exception
Fetches a list of changes needed to update the workspace to head.- Parameters:
fromRefs
- List from revisions- Returns:
- List of changes
- Throws:
Exception
- push up stack
-
listHaveChanges
public List<P4Ref> listHaveChanges(List<P4Ref> fromRefs, P4Ref changeLimit) throws Exception
Fetches a list of changes needed to update the workspace to the specified limit. The limit could be a Perforce change number, label or counter.- Parameters:
fromRefs
- List of from revisionschangeLimit
- To Revision- Returns:
- List of changes
- Throws:
Exception
- push up stack
-
getClientView
public com.perforce.p4java.impl.generic.client.ClientView getClientView()
-
isClientValid
public boolean isClientValid(Workspace workspace)
-
getClient
public com.perforce.p4java.client.IClient getClient()
-
-