Example scripts
To homepage
Bitbucket

Find branch by name
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.repository.RefService
import com.atlassian.bitbucket.repository.Repository
import com.atlassian.bitbucket.repository.ResolveRefRequest
import com.atlassian.sal.api.component.ComponentLocator
import com.onresolve.scriptrunner.parameters.annotation.RepositoryPicker
import com.onresolve.scriptrunner.parameters.annotation.ShortTextInput
import static com.atlassian.bitbucket.repository.StandardRefType.BRANCH
@RepositoryPicker(label = "Repository", description = "Enter the repository name")
Repository repository
@ShortTextInput(label = "Branch", description = "Enter the branch name")
String branchName
def refService = ComponentLocator.getComponent(RefService)
refService.resolveRef(new ResolveRefRequest.Builder(repository).with {
type(BRANCH)
refId("refs/heads/${branchName}")
}.build())
Having an issue with this script?
Report it here