Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

atlassian-connect-express 8: execute own code after app installation

Hello!

In this article we will talk how to execute your own code after somebody installed our app to Bitbucket.

This article is based on this one.

You can find the source code here.

You can watch the video for this article here.

Out of the box our app contains the following rest endpoint:

app.post('/installed', (req, res, next) => {
  req.body.baseUrl = req.body.baseApiUrl;
  next();
});

That is why you could think that it is just easy to add your code to this endpoint and everything will be fine. But it is not true. You never now know if your app was installed successfully or not by the installed endpoint within the atalssian-connect-express framework itself.

That is why you need to use the host_settings_saved event (you can find all events here).

To use the event add this code to backend/app.js:

addon.on('host_settings_saved', function(clientKey, data) {
    console.log('host_settings_saved')
    console.log(clientKey)
    console.log(data)
});

We can see that the event accepts clientKey and data. Data is the json which comes with the install request from Bitbucket. The same json you can find in the AddonSettings table for the client.

Now let’s install our app again and have a look at the logs:

host_settings_saved
connection:4192974
{
  productType: 'bitbucket',
  principal: {
    display_name: 'Alexey Matveev',
.....

Which means that the event was called and now we can execute our own post installation actions.

1 comment

Mohammed Amine Community Leader Jun 03, 2021

Excellent content

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Jira issue check and more advanced commit verifications for Bitbucket DC

Pre-receive hooks that verify the Git commit message, the modified files, and implement similar code change controls used to be requirements of large enterprises working in regulated industries only....

36 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you