You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I need to get a pull request from the project, repository and pull request number with Script Runner. Usually I use the event but in this case I only have the repository slug and pull request ID.
After viewing some examples here https://www.programcreek.com/java-api-examples/index.php?api=com.atlassian.bitbucket.pull.PullRequest:
Figured this out:
import com.atlassian.bitbucket.pull.PullRequestSearchRequest
import com.atlassian.bitbucket.util.PageRequestImpl
import com.atlassian.bitbucket.util.PageRequest
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.bitbucket.repository.RepositoryService
import com.atlassian.bitbucket.repository.Repository
import com.atlassian.bitbucket.repository.RefService
import com.atlassian.bitbucket.pull.PullRequest
import static com.atlassian.bitbucket.pull.PullRequestState.OPEN;
import com.atlassian.bitbucket.pull.PullRequestService
import com.atlassian.bitbucket.pull.PullRequestUpdateRequest
def repositoryService = ComponentLocator.getComponent(RepositoryService.class);
def refService = ComponentLocator.getComponent(RefService.class);
Repository rep = repositoryService.getBySlug("Project1","Repo1");
int id = rep.getId();
log.warn(id.toString())
def pullRequestService = ComponentLocator.getComponent(PullRequestService)
PageRequest page = new PageRequestImpl(0, 10)
PullRequestSearchRequest pullr = new PullRequestSearchRequest.Builder().toRepositoryId(id).state(OPEN).build()
long pullrequestID
int version
log.warn(pullRequestService.search(pullr, page).getValues().toString())
pullRequestService.search(pullr,page).getValues().forEach( val -> {
//log.warn("ID: "+val.id+" Description "+val.getDescription())
pullrequestID = val.id
version = val.version
}
)
log.warn(pullRequestService.getById(id,pullrequestID).getDescription())
@Infantino Benitono need to make a paged request if you have a Project Key, Repository slug and pull request id. The following script should get you a single pull request where :
- Project Key = 'PROJECT_1'
- Repository Slug = 'rep_1'
- Pull Request id = '1'
```
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.