Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to start working with forge

shani.feldboy February 8, 2024

Hi all, 
we are trying to create a simple forge app that can check the commit message in the PR 
before merge 
i can not understend even where to start, not a lot of examples on how to use it and write the index.js or manifest.yml
tried using https://developer.atlassian.com/platform/forge/example-apps-bitbucket/#bitbucket-check-pull-request-title-app and fifnt succeeded
ill appricate any help :)

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Hillary Chan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 8, 2024

Hi @shani.feldboy ,

It sounds like you are looking to create a Custom Merge Check. The blog I linked gives you a high-level overview of how to get started such as onboarding your workspace and enabling checks for a repository.

We're aware our documentation on creating making a Custom Merge Check app is limited and are working on improving it. For now, I'll provide some additional instructions:

  1. You can create a Custom Merge Check template via the Forge CLI. 
    1. Run `forge create`
    2. Select category `Triggers and Validators`
    3. Select product `Bitbucket`
    4. Select `bitbucket-merge-check`
  2. Looking at `manifest.yml`, the created template app makes use of the module `bitbucket:mergeCheck`. See more details about this module here. The app listens to trigger `on-code-pushed` and invokes the function with key `main`. Other trigger types can be found on Triggers. Choose the triggers (you can listen to multiple) which you think are relevant to your use case.
  3. Looking at `src/index.js`, update your function handler to run the relevant code to confirm whether or not your PR satisfies the check. Your function handler 
    1. receives an invocation payload which provides details about the PR - more details here
    2. is expected to return a response payload which informs whether the check passed or not - more details here

 

I hope this helps and feel free to ask any additional questions if you encounter any issues.

Hillary

Garrett_LoVerde February 16, 2024

I'm willing to bet that most people thinking about using this, are comparing and contrasting this against bitbucket pipelines.

I checked these docs out a couple weeks ago and what isn't made immediately clear is how to interact with the code the pull request pertains to.

Yes, we could use bitbucket API's, lookup the PR and get the code. But there is no example showing how to do this.

It would be good to have a sample and guide that shows how merge checks could interact with the code associated with the PR.

Alternatively, if this isn't what custom merge checks are meant to be used for yet, then it would be good to communicate that clearly.

Like # people like this
Edmund Munday
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 27, 2024

@Garrett_LoVerde - this is a really excellent point and you are 100% correct. Something the team is working on right now is library of helper functions that is published as an NPM module that can be included in any Forge Apps being built.

These helper functions are designed to abstract away the complexity of common tasks exactly like the one you mentioned. Collecting the diff details of a PR is #1 on the list of tasks that we will be adding to this library.

This utility has not been added to the library yet - just to be clear, but it is something we have in our plan.

The package is available here: https://www.npmjs.com/package/@forge/bitbucket

Like # people like this
Garrett_LoVerde March 17, 2024

@Edmund Munday 

From what is public it looks like a small step in the right direction.

What I really need is to be able to intellisense my way into calling the API's without having to go look up the REST API and copy paste URI's.

I write C code for microcontrollers; anything that can be done to reduce the cognitive load outside of the already formidable load posed by react and it's conventions will be helpful.

I fully understand that you'll need to draw the line somewhere regarding who you consider a target user but it feels odd not being able to make API calls without copy pasting a URI.

I've been looking into creating a Repository Main Menu Page that is dedicated to viewing and setting pipeline schedules (BB's schedule viewer is near unusable).

My JS/TS data structure/transformation skills are so rusty that transforming the API response into a form that can be dropped into a UI-Kit2 dynamic table feels almost insurmountable at the moment. (Not much you can do for me on that)

1 vote
Edmund Munday
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 27, 2024

Hi @shani.feldboy - just checking in, how did you go with this, were you able to get up and running?

shani.feldboy March 18, 2024



Hi, 
ive manged to use it thanks !
now im stuck on getting group members using API 
im tring to run - 

.requestBitbucket(
                    route`1.0/groups/${workspace_name}/${group_name}/members`
                );

and im getting an error that this API is not found 
(we use it outside of Forge and it works)
any suggestions ?
Like Caterina Curti likes this
Hillary Chan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2024

Hi @shani.feldboy ,

1.0 REST endpoints are not available on Forge.

You can only use endpoints on https://developer.atlassian.com/cloud/bitbucket/rest/intro/ that have been marked with "Forge app scopes required:".

The closest equivalent endpoints on are

Like Caterina Curti likes this
shani.feldboy March 19, 2024

@Hillary Chan  -

Thanks but that's not what we needed
We check if a PR author is in a specific group
The process is -
1. Get the author PR via API call (works)
2. Get members in a specific group (doesn't work)
3. Check if #1 is a part of #2

Please advise
I tried using the links you sent but couldn't get a reply back

Hillary Chan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 19, 2024

Hi @shani.feldboy ,

Unfortunately there are no equivalent endpoints related to group permissions on our 2.0 APIs. If you would like this endpoint ported to our 2.0 APIs, please raise a new issue on https://jira.atlassian.com/projects/BCLOUD/summary for this request to be triaged by the relevant team. The issue should be raised under the project "Bitbucket Cloud (BCLOUD)"

TAGS
AUG Leaders

Atlassian Community Events