Class MergeWithGitSCMExtension
- java.lang.Object
-
- hudson.model.AbstractDescribableImpl<GitSCMExtension>
-
- hudson.plugins.git.extensions.GitSCMExtension
-
- jenkins.plugins.git.MergeWithGitSCMExtension
-
- All Implemented Interfaces:
Describable<GitSCMExtension>
public class MergeWithGitSCMExtension extends GitSCMExtension
Similar toPreBuildMerge
, but for use fromSCMSource
implementations that need to specify the exact base branch hash. The hash is specified so that we are not subject to a race condition between thebaseHash
we think we are merging with and a possibly newer one that was just pushed.IMPORTANT This extension is intended for programmatic use only. It must be the last extension in the list of extensions or else some other extension may turn on shallow cloning.
- Since:
- 3.5.0
-
-
Constructor Summary
Constructors Constructor Description MergeWithGitSCMExtension(String baseName, String baseHash)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
decorateCloneCommand(GitSCM scm, Run<?,?> build, org.jenkinsci.plugins.gitclient.GitClient git, TaskListener listener, org.jenkinsci.plugins.gitclient.CloneCommand cmd)
Called before aCloneCommand
is executed to allow extensions to alter its behaviour.void
decorateFetchCommand(GitSCM scm, org.jenkinsci.plugins.gitclient.GitClient git, TaskListener listener, org.jenkinsci.plugins.gitclient.FetchCommand cmd)
Deprecated.hudson.plugins.git.Revision
decorateRevisionToBuild(GitSCM scm, Run<?,?> build, org.jenkinsci.plugins.gitclient.GitClient git, TaskListener listener, hudson.plugins.git.Revision marked, hudson.plugins.git.Revision rev)
Called afterBuildChooser
selects the revision to pick for this build, but beforeString
getBaseHash()
String
getBaseName()
-
Methods inherited from class hudson.plugins.git.extensions.GitSCMExtension
beforeCheckout, beforeCheckout, decorate, decorateCheckoutCommand, decorateCheckoutCommand, decorateCloneCommand, decorateFetchCommand, decorateMergeCommand, decorateMergeCommand, decorateRevisionToBuild, determineSupportForJGit, enableMultipleRevisionDetection, getDescriptor, getRequiredClient, getWorkingDirectory, getWorkingDirectory, isRevExcluded, onCheckoutCompleted, onCheckoutCompleted, onClean, populateEnvironmentVariables, requiresWorkspaceForPolling
-
-
-
-
Method Detail
-
getBaseName
@NonNull public String getBaseName()
-
getBaseHash
public String getBaseHash()
-
decorateCloneCommand
public void decorateCloneCommand(GitSCM scm, Run<?,?> build, org.jenkinsci.plugins.gitclient.GitClient git, TaskListener listener, org.jenkinsci.plugins.gitclient.CloneCommand cmd) throws IOException, InterruptedException, hudson.plugins.git.GitException
Description copied from class:GitSCMExtension
Called before aCloneCommand
is executed to allow extensions to alter its behaviour.- Overrides:
decorateCloneCommand
in classGitSCMExtension
- Parameters:
scm
- GitSCM objectbuild
- run contextgit
- GitClientlistener
- build logcmd
- clone command to be decorated- Throws:
IOException
- on input or output errorInterruptedException
- when interruptedhudson.plugins.git.GitException
- on git error
-
decorateFetchCommand
@Deprecated public void decorateFetchCommand(GitSCM scm, org.jenkinsci.plugins.gitclient.GitClient git, TaskListener listener, org.jenkinsci.plugins.gitclient.FetchCommand cmd) throws IOException, InterruptedException, hudson.plugins.git.GitException
Deprecated.Description copied from class:GitSCMExtension
Called before aFetchCommand
is executed to allow extensions to alter its behaviour.- Overrides:
decorateFetchCommand
in classGitSCMExtension
- Parameters:
scm
- GitSCM objectgit
- GitClientlistener
- build logcmd
- fetch command to be decorated- Throws:
IOException
- on input or output errorInterruptedException
- when interruptedhudson.plugins.git.GitException
- on git error
-
decorateRevisionToBuild
public hudson.plugins.git.Revision decorateRevisionToBuild(GitSCM scm, Run<?,?> build, org.jenkinsci.plugins.gitclient.GitClient git, TaskListener listener, hudson.plugins.git.Revision marked, hudson.plugins.git.Revision rev) throws IOException, InterruptedException, hudson.plugins.git.GitException
Description copied from class:GitSCMExtension
Called afterBuildChooser
selects the revision to pick for this build, but beforeThis allows extensions to select a derived revision (for example by merging another branch into the chosen revision and returning it) or manipulate the state of the working tree (such as running git-clean.)
GitSCMExtension.decorateRevisionToBuild(GitSCM, Run, GitClient, TaskListener, Revision, Revision)
vsBuildChooser
BuildChooser
and this method are similar in the sense that they both participate in the process of determining what commits to build. So when a plugin wants to control the commit to be built, you have a choice of these two approaches. The rule of the thumb is to ask yourself if your process takes another commit as an input.BuildChooser
is suitable when you do not take any commit as a parameter, and need to precisely control what commit to build. For example the gerrit-trigger plugin looks at a specific build parameter, then retrieves that commit from Gerrit and builds that.GitSCMExtension.decorateRevisionToBuild(GitSCM, Run, GitClient, TaskListener, Revision, Revision)
is suitable when you accept arbitrary revision as an input and then create some derivative commits and then build that result. The primary example is for speculative merge with another branch (people use this to answer the question of "what happens if I were to integrate this feature branch back to the master branch?")- Overrides:
decorateRevisionToBuild
in classGitSCMExtension
- Parameters:
scm
- GitSCM objectbuild
- run contextgit
- GitClient objectlistener
- build logmarked
- The revision that started this build. (e.g. pre-merge)rev
- The revision selected for this build.- Returns:
- The revision selected for this build. Unless you are decorating the given
rev
, return the value given in therev
parameter. - Throws:
IOException
- on input or output errorInterruptedException
- when interruptedhudson.plugins.git.GitException
- on git error
-
-