Add field to PR?

I have a client asking if we can add a per-user field to the PR screen. Once filled out, I would need to send that field’s value to Jira (the user is authenticated in both systems - SSO). I am quite familiar with Jira add-on development and have a clear vision of the Jira side of things, but I can’t seem to find good info on Bitbucket.

  1. Is it possible to add a custom field to the PR screen?
  2. Can this field be per-user?
  3. Is there a “trigger” on update/save of that custom field that I could tie into to make the Jira API call?

A dialog/wizard approach would also work.

More detail:
It’s a time tracking field - so their developers don’t have to go into Jira and find the correct issue to assign the time to (their Jira issue hierarchy is complex). They fill it out during the review and we would attach it as a work log to the correct issue.

1 Like

Hi @DerekWhite, if you want to customize the Bitbucket Pull Request screen, in Bitbucket 7+, you can start using Client-Side Extensions.

You can check the guide on how to start using CSE:
https://developer.atlassian.com/server/framework/clientside-extensions/guides/introduction/

Here is the link to the plugin project template you can use to develop your custom plugin:
https://bitbucket.org/atlassianlabs/bitbucket-client-side-extensions-template

  1. Can this field be per-user?
  2. Is there a “trigger” on update/save of that custom field that I could tie into to make the Jira API call?

I can suggest creating a custom REST endpoint in the plugin that can communicate with the frontend part.

There are a couple of guides related to plugin development you can check here:
https://developer.atlassian.com/server/bitbucket/how-tos/beginner-guide-to-bitbucket-server-plugin-development/

Thanks,
Maciej Adamczak
Atlassian Developer

2 Likes

@madamczak Thanks for pointing out CSE. It does seem to provide a pathway for what my client needs and verifies their request is worth pursuing further.

Much better than whatever custom field based Jira-type system I was thinking along the lines of. Tysm!

1 Like

I began development on the feature. It involves using the Jira Issue linked to a pull request to make a couple API calls to Jira as the current user.

CSE doesn’t appear to provide access to the PR’s linked Jira Issues in the context (I chose not to use document.querySelector() to scrape them) and I need to perform a bit of logic, so I have added a REST module to the plugin.

The CSE now opens a dialog, collects a bit of information from the user, and passes the inputs plus the repo and pr ids from the context to the non-anonymous REST endpoint I added.

Inside the controller, the repo and pr ids from the request entity are used with JiraIssueService to get the linked issues. I am now ready to do some Jira API calls…

The apps are linked, users are the same, etc.

How do I use the current user’s auth with these calls to Jira?

  • Guessing Application links?
  • Or, do I have to get into 3LO?
  • If I stop where I am and return the linked issue keys back to the UI, are there any helpers in JS for using Jira API/OAuth?