Package io.jenkins.plugins.gitcollect
Class GitScanner
- All Implemented Interfaces:
FilePath.FileCallable<LocalGitInfo>,Serializable,ControllerToAgentFileCallable<LocalGitInfo>,org.jenkinsci.remoting.RoleSensitive
A file callable that executes on the agent (slave) to extract Git repository information.
This class extends MasterToSlaveFileCallable, allowing it to be sent from the
Jenkins controller to the agent where the workspace resides. It interacts with the
local file system using the GitClient to resolve revisions and remote URLs.
It returns a LocalGitInfo object containing serializable data about the
repository state, which is then sent back to the controller.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGitScanner(org.jenkinsci.plugins.gitclient.GitClient git, String markedCommit, String remote) Constructs a new GitScanner. -
Method Summary
Modifier and TypeMethodDescriptionExecutes the scanning logic in the workspace.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jenkins.agents.ControllerToAgentFileCallable
checkRoles
-
Field Details
-
LOGGER
-
-
Constructor Details
-
GitScanner
public GitScanner(org.jenkinsci.plugins.gitclient.GitClient git, String markedCommit, String remote) Constructs a new GitScanner.- Parameters:
git- TheGitClientinitialized for the specific workspace directory.markedCommit- A specific commit hash or branch name to resolve as the "marked" revision.remote- Specify the remote name
-
-
Method Details
-
invoke
public LocalGitInfo invoke(File workspace, hudson.remoting.VirtualChannel channel) throws IOException, InterruptedException Executes the scanning logic in the workspace.This method performs the following steps:
- Retrieves the remote URL for "origin".
- Resolves the SHA1 ID for the
markedCommit(or HEAD). - Resolves the SHA1 ID for the current HEAD (the built revision).
- Constructs
Revisionobjects for both the marked and built states. - Extracts the "humanish" name from the remote URL.
- Parameters:
workspace- The root directory of the workspace on the agent.channel- The virtual channel to the controller.- Returns:
- A
LocalGitInfoobject containing the gathered repository data. - Throws:
IOException- If an I/O error occurs, or if Git revisions cannot be resolved.InterruptedException- If the operation is interrupted.
-