Package org.jenkinsci.plugins.p4.client
Class ConnectionHelper
- java.lang.Object
-
- org.jenkinsci.plugins.p4.client.CredentialsHelper
-
- org.jenkinsci.plugins.p4.client.SessionHelper
-
- org.jenkinsci.plugins.p4.client.ConnectionHelper
-
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
ClientHelper
public class ConnectionHelper extends SessionHelper implements AutoCloseable
-
-
Constructor Summary
Constructors Constructor Description ConnectionHelper(ItemGroup context, String credentialID, TaskListener listener)
ConnectionHelper(Item job, String credentialID, TaskListener listener)
ConnectionHelper(Run run, String credentialID, TaskListener listener)
ConnectionHelper(String credentialID, TaskListener listener)
Deprecated.ConnectionHelper(P4BaseCredentials credential)
ConnectionHelper(P4BaseCredentials credential, TaskListener listener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
buildRevisionLimit(String path, P4Ref from, P4Ref to)
Build a revision limit spec.void
close()
String
counterToChange(String name)
Look for a counter and return a change or reference.void
deleteClient(String name)
Delete a client workspaceList<com.perforce.p4java.core.file.IFileSpec>
getChangeFiles(long id, int limit)
com.perforce.p4java.core.IChangelistSummary
getChangeSummary(long id)
List<com.perforce.p4java.core.file.IFileSpec>
getCommitFiles(String repo, String sha)
String
getCounter(String id)
Get Perforce CounterList<com.perforce.p4java.core.file.IFileSpec>
getDirs(List<String> paths)
Gets a list of Dirs given a path (multi-branch?)String
getEmail(String userName)
com.perforce.p4java.graph.ICommit
getGraphCommit(String sha, String repo)
P4Ref
getGraphHead(String repo)
Get the last SHA commited to the specified repo.long
getHead(String path, P4Ref from, P4Ref to)
Get the latest change on the given pathlong
getHeadLimit()
List<com.perforce.p4java.core.IFix>
getJobs(int id)
com.perforce.p4java.impl.generic.core.Label
getLabel(String id)
Get Perforce LabelList<com.perforce.p4java.core.file.IFileSpec>
getLabelFiles(String id, int limit)
Find all files within a label or change.long
getLowestHead(String path, P4Ref from, P4Ref to)
Get the lowest change on the given pathprotected int
getMaxChangeLimit()
List<com.perforce.p4java.core.file.IFileSpec>
getShelvedFiles(int id)
Find all files within a shelf.List<com.perforce.p4java.core.IStreamSummary>
getStreams(List<String> paths)
Gets a list of Dirs given a path (multi-stream?)String
getSwarm()
boolean
hasFile(String depotPath)
boolean
isClient(String name)
Test if given name is a clientboolean
isCounter(String name)
Test if given name is a counterboolean
isLabel(String name)
Test if given name is a labelString
labelToChange(String name)
Look for a label and return a change or static label.List<com.perforce.p4java.core.IRepo>
listAllRepos()
List all Graph ReposList<P4Ref>
listCommits(List<P4Ref> fromRefs, P4Ref to)
List graph Commits with in range of SHAsList<com.perforce.p4java.core.IRepo>
listRepos(String path)
List of Graph Repos based on a pathvoid
setLabel(com.perforce.p4java.impl.generic.core.Label label)
Create/Update a Perforce Label-
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
-
ConnectionHelper
@Deprecated public ConnectionHelper(String credentialID, TaskListener listener) throws IOException
Deprecated.- Throws:
IOException
-
ConnectionHelper
public ConnectionHelper(ItemGroup context, String credentialID, TaskListener listener) throws IOException
- Throws:
IOException
-
ConnectionHelper
public ConnectionHelper(Item job, String credentialID, TaskListener listener) throws IOException
- Throws:
IOException
-
ConnectionHelper
public ConnectionHelper(Run run, String credentialID, TaskListener listener) throws IOException
- Throws:
IOException
-
ConnectionHelper
public ConnectionHelper(P4BaseCredentials credential, TaskListener listener) throws IOException
- Throws:
IOException
-
ConnectionHelper
public ConnectionHelper(P4BaseCredentials credential) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getDirs
public List<com.perforce.p4java.core.file.IFileSpec> getDirs(List<String> paths) throws Exception
Gets a list of Dirs given a path (multi-branch?)- Parameters:
paths
- list of paths to look for dirs (only takes * as wildcard)- Returns:
- list of dirs or empty list
- Throws:
Exception
- push up stack
-
getStreams
public List<com.perforce.p4java.core.IStreamSummary> getStreams(List<String> paths) throws Exception
Gets a list of Dirs given a path (multi-stream?)- Parameters:
paths
- list of path to look for streams (takes ... or * as wildcard)- Returns:
- list of streams or empty list
- Throws:
Exception
- push up stack
-
getChangeSummary
public com.perforce.p4java.core.IChangelistSummary getChangeSummary(long id) throws com.perforce.p4java.exception.P4JavaException
- Throws:
com.perforce.p4java.exception.P4JavaException
-
getJobs
public List<com.perforce.p4java.core.IFix> getJobs(int id) throws com.perforce.p4java.exception.P4JavaException
- Throws:
com.perforce.p4java.exception.P4JavaException
-
isCounter
public boolean isCounter(String name) throws Exception
Test if given name is a counter- Parameters:
name
- Couner name- Returns:
- true if counter
- Throws:
Exception
- push up stack
-
getCounter
public String getCounter(String id) throws Exception
Get Perforce Counter- Parameters:
id
- Counter name- Returns:
- Perforce Counter
- Throws:
Exception
- push up stack
-
isLabel
public boolean isLabel(String name) throws Exception
Test if given name is a label- Parameters:
name
- Label name- Returns:
- true if label.
- Throws:
Exception
- push up stack
-
labelToChange
public String labelToChange(String name)
Look for a label and return a change or static label.- Parameters:
name
- label- Returns:
- change reference or null if no label found.
-
counterToChange
public String counterToChange(String name)
Look for a counter and return a change or reference.- Parameters:
name
- counter- Returns:
- change reference or null if no counter found.
-
isClient
public boolean isClient(String name) throws Exception
Test if given name is a client- Parameters:
name
- Client name- Returns:
- true if client exists.
- Throws:
Exception
- push up stack
-
deleteClient
public void deleteClient(String name) throws Exception
Delete a client workspace- Parameters:
name
- Client name- Throws:
Exception
- push up stack
-
getLabel
public com.perforce.p4java.impl.generic.core.Label getLabel(String id) throws Exception
Get Perforce Label- Parameters:
id
- Label name- Returns:
- Perforce Label
- Throws:
Exception
- push up stack
-
setLabel
public void setLabel(com.perforce.p4java.impl.generic.core.Label label) throws Exception
Create/Update a Perforce Label- Parameters:
label
- Label name- Throws:
Exception
- push up stack
-
getLabelFiles
public List<com.perforce.p4java.core.file.IFileSpec> getLabelFiles(String id, int limit) throws Exception
Find all files within a label or change. (Max results limited by limit)- Parameters:
id
- Label name or change number (as string)limit
- Max results (-m value)- Returns:
- List of file specs
- Throws:
Exception
- push up stack
-
getChangeFiles
public List<com.perforce.p4java.core.file.IFileSpec> getChangeFiles(long id, int limit) throws Exception
- Throws:
Exception
-
getShelvedFiles
public List<com.perforce.p4java.core.file.IFileSpec> getShelvedFiles(int id) throws Exception
Find all files within a shelf.- Parameters:
id
- Shelf ID- Returns:
- List of file specs
- Throws:
Exception
- push up stack
-
getSwarm
public String getSwarm() throws com.perforce.p4java.exception.P4JavaException
- Throws:
com.perforce.p4java.exception.P4JavaException
-
getHead
public long getHead(String path, P4Ref from, P4Ref to) throws Exception
Get the latest change on the given path- Parameters:
path
- Perforce depot path //foo/...from
- From revision (change or label)to
- To revision (change or label)- Returns:
- change number
- Throws:
Exception
- push up stack
-
buildRevisionLimit
protected String buildRevisionLimit(String path, P4Ref from, P4Ref to)
Build a revision limit spec.- Parameters:
path
- Perforce depot or client path //foo/...from
- From revision (change or label)to
- To revision (change or label)- Returns:
- a Perforce Revision Spec
-
getLowestHead
public long getLowestHead(String path, P4Ref from, P4Ref to) throws Exception
Get the lowest change on the given path- Parameters:
path
- Perforce depot path //foo/...from
- revision specifierto
- revision specifier- Returns:
- change number
- Throws:
Exception
- push up stack
-
getGraphCommit
public com.perforce.p4java.graph.ICommit getGraphCommit(String sha, String repo) throws com.perforce.p4java.exception.P4JavaException
- Throws:
com.perforce.p4java.exception.P4JavaException
-
getCommitFiles
public List<com.perforce.p4java.core.file.IFileSpec> getCommitFiles(String repo, String sha) throws com.perforce.p4java.exception.P4JavaException
- Throws:
com.perforce.p4java.exception.P4JavaException
-
getGraphHead
public P4Ref getGraphHead(String repo)
Get the last SHA commited to the specified repo.- Parameters:
repo
- a graph repo- Returns:
- a P4Ref of the last commit
-
listCommits
public List<P4Ref> listCommits(List<P4Ref> fromRefs, P4Ref to) throws Exception
List graph Commits with in range of SHAs- Parameters:
fromRefs
- Array of potential SHAs (include other repos)to
- The last SHA to list commits- Returns:
- a List or Commits
- Throws:
Exception
- push up stack
-
listAllRepos
public List<com.perforce.p4java.core.IRepo> listAllRepos() throws Exception
List all Graph Repos- Returns:
- A list of Graph Repos
- Throws:
Exception
- push up stack
-
listRepos
public List<com.perforce.p4java.core.IRepo> listRepos(String path) throws Exception
List of Graph Repos based on a path- Parameters:
path
- Path filter- Returns:
- A list of Graph Repos
- Throws:
Exception
- push up stack
-
getMaxChangeLimit
protected int getMaxChangeLimit()
-
getHeadLimit
public long getHeadLimit()
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
-