Example scripts
To homepage
Bitbucket

Rebase branch
App in script

ScriptRunner For Bitbucket
by Adaptavist
Compatibility

Bitbucket (6.0 - 7.17)

ScriptRunner For Bitbucket (7.10.0)
Language |
groovy
import com.atlassian.bitbucket.scm.git.command.GitExtendedCommandFactory
import com.atlassian.bitbucket.scm.git.command.GitRebaseCommandParameters
import com.atlassian.bitbucket.user.ApplicationUser
import com.atlassian.sal.api.component.ComponentLocator
import com.onresolve.scriptrunner.bitbucket.branch.BranchWithRepository
import com.onresolve.scriptrunner.parameters.annotation.BranchPicker
import com.onresolve.scriptrunner.parameters.annotation.UserPicker
@BranchPicker(label = "Upstream branch to rebase from", description = "Enter the name of the upstream branch")
BranchWithRepository upstreamBranch
@BranchPicker(label = "Branch to rebase", description = "Enter the name of the branch to rebase")
BranchWithRepository branchToRebase
@UserPicker(label = "Rebasing user", description = "User the rebase will be performed as")
ApplicationUser rebasingUser
def gitExtendedCommandFactory = ComponentLocator.getComponent(GitExtendedCommandFactory)
def rebaseCommand = gitExtendedCommandFactory.rebase(branchToRebase.repository,
new GitRebaseCommandParameters.Builder(branchToRebase, upstreamBranch.latestCommit)
.committer(rebasingUser)
.commitRequired(false)
.upstreamRepository(upstreamBranch.repository)
.build())
rebaseCommand.call()
Having an issue with this script?
Report it here