Script runner bitbucket package and api

I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 7, 2024

I’m trying to solve a problem where in.

Fetch the latest commit from the pull request and the develop branch. Compare the time the build of both by getting the build information of the latest commit on both. If the time of the build on develop is ahead of the pull request then veto “ there’s a commit in development branch, please trigger a new build manually”

This will block the pull request from getting merged without triggering a new build.


This is a custom merge check script for 7.x. I’m unable to find a similar package of buildservice which is deprecated in 8.X.

import com.atlassian.sal.api.component.ComponentLocator import import

def buildService = ComponentLocator.getComponent(BuildService)

def repository = repository

def pullRequest = pullRequest

def prBuilds = buildService.getBuilds(repository, pullRequest.getFromRef).getLatestCommit())

def developBuilds = buildService.getBuilds(repository, "develop")

def prLatestBuildTime = prBuilds.getValues).max { it.dateStarted.time }

def developLatestBuild Time = developBuilds.getValues).max { it .dateStarted.time }

if (developLatestBuild Time > prLatestBuild Time) {

veto ("Develop build is newer, merge blocked. Please trigger a new build manually”)


0 answers

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events