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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,555,109
Community Members
 
Community Events
184
Community Groups

How to notify Microsoft Teams from Bitbucket Pipeline?

Hey there, I'm new to Bitbucket Pipelines, and am trying to see if I can duplicate my Jenkins pipelines' functionality with a pipeline on Bitbucket.

I've got a pipeline running, but I can't seem to get it to notify us when it's finished running.

Here's what I'm trying to do: update a Teams channel when a pipeline build has started or completed. When it's completed, I'd like to post its build status. That's it. Nothing fancy.

Here's as far as I've gotten:

  1. created an internal webhook in my Teams channel
  2. set up a webhook in my repo in my-repo> Settings > Webhooks using the URL generated in step 1. chose ""Build status created" and "Build Status updated" as the Triggers"
  3. Made a change on a branch of my-repo and pushed the change up
  4. Watched the build start and finish
  5. Watched no notifications come into the Teams channel.

Any ideas what steps I might be missing? I'm on Bitbucket Cloud, btw.

5 answers

1 accepted

2 votes
Answer accepted

I found the solution myself, albeit a very basic one: set this up as an item in the "script" portion of after-script:

- curl -H "Content-Type: application/json" -d "{'text':'Hello World'}" https://<WEBHOOK URL> 

 

Here's why I got snagged up: I was following the Microsoft docs  for formatting the -d argument, but was getting a linting error in 'text': 'Hello World' because VS Code's linter, the Redhat YAML extension, was seeing the space after the colon in that payload and was barking about me trying to submit YAML. I removed the space, the barking stopped, the notification happened. 

Now I get to go down the fun rabbit hole of string interpolation and passing variables inside single quotes, which bash hates.

Update: Thank you @inger_klekacz the issue was with space after "Content-Type:

 

Hi @inger_klekacz am trying to do the same thing, from normal terminal if I use this

 

curl -H "Content-Type: application/json" -d "{'text':'Sample msg'}" <WEBHOOK_URL>

It works notification happened.

 

but If I use

script:

- curl -H "Content-Type: application/json" -d "{'text':'Sample msg'}" <WEBHOOK_URL>
pipeline fails with There is an error in your bitbucket-pipelines.yml msg
when I checked in linting tool it shows either I have to use string or pipe
Like Mikhail Smirnov likes this

Hello,

please I’m trying to implement this as well into my pipeline. I will like to connect with you and see how you achieved this please. Thanks

Below is the pipeline that you could use that worked for me

# MS TEams Notification
image: atlassian/default-image:3

pipelines:
   default:
      - parallel:
           - step:
               name: 'MSTeamsNotification'
               script:
                    - echo "Teams Bitbucket Pipeline Notification...from Nataraj.."
                    - curl -d "{\"text\":\"Message from Bitbucket Pipelinedata...\"}" -H "Content-Type:application/json" $TEAMS_WEBHOOK_URL

 

Thanks,

Nataraj

Nataraj please I tried this and no notifications. Help?

you could use the below command line

 

- curl -d "{\"text\":\"Message from Bitbucket Pipelinedata...\"}" -H "Content-Type:application/json" $TEAMS_WEBHOOK_URL

0 votes
Move Work Forward
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jan 29, 2021

Hello @inger_klekacz ,

 

You can use Microsoft Teams Bitbucket Connector. There is a short guide on how to set it up, but otherwise it is pretty simple.

 

If you have any questions please feel free to reach out.

 

Regards,

Leo

That was my first attempt, but it seemed like it supported everything except build status, which is basically the only thing I need right now. BTW when I was trying to figure it out, I clicked on the Support > Documentation link from the Marketplace link you posted, and the docs link was a 404. Thanks anyway, though.

Like Paul Rohorzka likes this

@inger_klekacz thanks, actually that's also what we need. From what I can tell the connector simply handles notifications globally around repository operations whereas we needed custom notifications issued from within pipelines on a per step basis.

Like Paul Rohorzka likes this

Tried the Microsoft Teams Bitbucket Connector a year later (2/2022) but it still does not support pipeline events.

Move Work Forward
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Feb 18, 2022

Hi @Daniel Toplak 

Thanks for the comment.

The Bitbucket does not send pipeline events to 3rd party apps. You can get notifications for commit status update events. This blog post could be useful.

If you could elaborate what you are trying to do - We can see if we can improve our Microsoft Teams Bitbucket Connector to serve you better.

Thanks,
Leo | Move Work Forward

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events