org.paylogic.jenkins.advancedscm.backends
Class GitBackend

java.lang.Object
  extended by org.paylogic.jenkins.advancedscm.backends.GitBackend
All Implemented Interfaces:
AdvancedSCMManager

public class GitBackend
extends Object
implements AdvancedSCMManager


Constructor Summary
GitBackend(hudson.model.AbstractBuild build, hudson.Launcher launcher, hudson.model.BuildListener listener, hudson.plugins.git.GitSCM scm)
           
 
Method Summary
 void clean()
          Cleans workspace from artifacts.
 void closeBranch(String message, String username)
          Close given branch.
 void commit(String message, String username)
          Commit the workspace changes with the given message.
 String getBranch()
          Get the current branch name in the workspace.
 List<Branch> getBranches(boolean all)
          Get Mercurial branches from command line output, and put them in a List with Branches so it's nice to work with.
 List<String> getBranchNames(boolean all)
          Get Mercurial branches from command line output, and put them in a List so it's nice to work with.
 String merge()
          Merge possible current branch's heads.
 String mergeWorkspaceWith(String revision)
          Merge current workspace with given revision.
 String mergeWorkspaceWith(String revision, String updateTo)
          Update workspace to 'updateTo' and then merge that workspace with 'revision'.
 String pull()
          Executes 'pull' command
 String pull(String remote)
          Pulls changes from remotes.
 String pull(String remote, String branch)
          Pulls from given repository url.
 String push(String... branchNames)
          Executes 'push' command for given branches
 void stripLocal()
          Strip out local commits which are not pushed yet.
 void update(String revision)
          Updates workspace to given revision/branch.
 void updateClean(String revision)
          Updates workspace to given revision/branch with cleaning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GitBackend

public GitBackend(hudson.model.AbstractBuild build,
                  hudson.Launcher launcher,
                  hudson.model.BuildListener listener,
                  hudson.plugins.git.GitSCM scm)
           throws Exception
Throws:
Exception
Method Detail

getBranches

public List<Branch> getBranches(boolean all)
Get Mercurial branches from command line output, and put them in a List with Branches so it's nice to work with.

Specified by:
getBranches in interface AdvancedSCMManager
Parameters:
all - : get all or only open branches
Returns:
List of Branches

getBranchNames

public List<String> getBranchNames(boolean all)
Get Mercurial branches from command line output, and put them in a List so it's nice to work with.

Specified by:
getBranchNames in interface AdvancedSCMManager
Parameters:
all - : get all or only open branches
Returns:
List of String

getBranch

public String getBranch()
Get the current branch name in the workspace.

Specified by:
getBranch in interface AdvancedSCMManager
Returns:
String with branch name in it.

update

public void update(String revision)
            throws AdvancedSCMException
Updates workspace to given revision/branch.

Specified by:
update in interface AdvancedSCMManager
Parameters:
revision - : String with revision, hash of branchname to update to.
Throws:
AdvancedSCMException

updateClean

public void updateClean(String revision)
                 throws AdvancedSCMException
Updates workspace to given revision/branch with cleaning.

Specified by:
updateClean in interface AdvancedSCMManager
Parameters:
revision - : String with revision, hash of branchname to update to.
Throws:
AdvancedSCMException

stripLocal

public void stripLocal()
                throws AdvancedSCMException
Strip out local commits which are not pushed yet.

Specified by:
stripLocal in interface AdvancedSCMManager
Throws:
AdvancedSCMException

clean

public void clean()
           throws AdvancedSCMException
Cleans workspace from artifacts.

Specified by:
clean in interface AdvancedSCMManager
Throws:
AdvancedSCMException

commit

public void commit(String message,
                   String username)
            throws AdvancedSCMException
Commit the workspace changes with the given message.

Specified by:
commit in interface AdvancedSCMManager
Parameters:
message - : String with message to give this commit.
username -
Throws:
AdvancedSCMException

mergeWorkspaceWith

public String mergeWorkspaceWith(String revision)
                          throws AdvancedSCMException
Merge current workspace with given revision. Do not forget to commit merge afterwards manually.

Specified by:
mergeWorkspaceWith in interface AdvancedSCMManager
Parameters:
revision - : String with revision, hash or branchname to merge with.
Returns:
String : Output of merge command (should be empty if all went well)
Throws:
AdvancedSCMException

merge

public String merge()
             throws AdvancedSCMException
Merge possible current branch's heads.

Specified by:
merge in interface AdvancedSCMManager
Returns:
String : Output of merge command (should be empty if all went well)
Throws:
AdvancedSCMException

mergeWorkspaceWith

public String mergeWorkspaceWith(String revision,
                                 String updateTo)
                          throws AdvancedSCMException
Update workspace to 'updateTo' and then merge that workspace with 'revision'. Do not forget to commit merge afterwards manually.

Specified by:
mergeWorkspaceWith in interface AdvancedSCMManager
Parameters:
revision - : String with revision, hash or branchname to merge with.
updateTo - : String with revision, hash or branchname to update to before merge.
Returns:
String : output of command run.
Throws:
AdvancedSCMException

push

public String push(String... branchNames)
            throws AdvancedSCMException
Executes 'push' command for given branches

Specified by:
push in interface AdvancedSCMManager
Throws:
AdvancedSCMException

pull

public String pull()
            throws AdvancedSCMException
Executes 'pull' command

Specified by:
pull in interface AdvancedSCMManager
Throws:
AdvancedSCMException

pull

public String pull(String remote)
            throws AdvancedSCMException
Pulls changes from remotes. Give it a remote to pull changes from there.

Specified by:
pull in interface AdvancedSCMManager
Parameters:
remote -
Throws:
AdvancedSCMException

closeBranch

public void closeBranch(String message,
                        String username)
                 throws AdvancedSCMException
Close given branch. Execute hg commit --close-branch -m"message".

Specified by:
closeBranch in interface AdvancedSCMManager
Parameters:
message - : String with message to give this commit.
Throws:
AdvancedSCMException

pull

public String pull(String remote,
                   String branch)
            throws AdvancedSCMException
Pulls from given repository url. Give it a remote to pull changes from there.

Specified by:
pull in interface AdvancedSCMManager
Parameters:
remote -
branch -
Throws:
AdvancedSCMException


Copyright © 2004-2014. All Rights Reserved.