Package io.jenkins.plugins.gitcollect
Class CollectGitStep
java.lang.Object
hudson.tasks.BuildStepCompatibilityLayer
hudson.tasks.Builder
io.jenkins.plugins.gitcollect.CollectGitStep
- All Implemented Interfaces:
ExtensionPoint,Describable<Builder>,BuildStep,SimpleBuildStep
A Jenkins build step that collects Git repository information from a local workspace directory
and registers it with the current build.
This step allows a build to recognize a directory as a Git repository even if the checkout was not performed by the standard Git SCM plugin during the current stage (e.g., if the repo was generated, restored from cache, or checked out by a script).
It populates BuildData actions, allowing subsequent steps to access Git
revision data and optionally generating changelogs.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface hudson.tasks.BuildStep
BuildStep.PublisherListNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudsonNested classes/interfaces inherited from interface jenkins.tasks.SimpleBuildStep
SimpleBuildStep.LastBuildAction, SimpleBuildStep.LastBuildActionFactory -
Field Summary
FieldsFields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the changelog generation flag.Gets the marked commit reference.getPath()Gets the relative path to the git directory.Gets the remote branch.voidperform(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) Executes the build step.voidsetChangelog(boolean changelog) Sets whether to generate a changelog.voidsetMarkedCommit(String markedCommit) Sets the specific commit or branch to mark as the previous baseline.voidSets the relative path to the git directory.voidSets the specific remote name (origin, m, ...).Methods inherited from class hudson.tasks.Builder
all, getDescriptor, getRequiredMonitorService, prebuildMethods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectAction, getProjectActions, perform, perform, prebuildMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface hudson.tasks.BuildStep
getProjectAction, getProjectActions, getRequiredMonitorService, perform, prebuildMethods inherited from interface jenkins.tasks.SimpleBuildStep
perform, perform, requiresWorkspace
-
Field Details
-
LOGGER
-
-
Constructor Details
-
CollectGitStep
@DataBoundConstructor public CollectGitStep()Default constructor for DataBound instantiation.
-
-
Method Details
-
setPath
Sets the relative path to the git directory.- Parameters:
path- The path relative to the workspace root.
-
getPath
Gets the relative path to the git directory.- Returns:
- The path, or null.
-
setChangelog
@DataBoundSetter public void setChangelog(boolean changelog) Sets whether to generate a changelog.- Parameters:
changelog-trueto enable changelog generation.
-
getChangelog
Gets the changelog generation flag.- Returns:
trueif changelog generation is enabled.
-
setRemote
Sets the specific remote name (origin, m, ...).- Parameters:
remote- Set the remote name.
-
getRemote
Gets the remote branch.- Returns:
- The return the remote name.
-
setMarkedCommit
Sets the specific commit or branch to mark as the previous baseline.- Parameters:
markedCommit- A SHA1 hash or branch name (e.g., "master").
-
getMarkedCommit
Gets the marked commit reference.- Returns:
- The marked commit string.
-
perform
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOExceptionExecutes the build step.This method performs the following actions:
- Resolves the Git directory path.
- Validates that the directory is a Git repository.
- Scans the repository using
GitScannerto retrieve remote URLs and revisions. - Optionally generates a changelog if requested and differences are found.
- Creates a
BuildDataobject and attaches it to the run actions. - Attaches
MultiScmEnvActionfor environment variable contribution.
- Specified by:
performin interfaceSimpleBuildStep- Parameters:
run- The current build.workspace- The project workspace.launcher- The launcher.listener- The build listener for logging.- Throws:
InterruptedException- If the operation is interrupted.IOException- If an I/O error occurs (e.g., repo not found).
-