avatarMirco on Tech

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2032

Abstract

have one. Click on the dots beside the team name and choose <code>Add Channel</code>.</p><figure id="c7c4"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*6UCXhmzF_xWmDD5ks9dQow.png"><figcaption>Add a new channel in Teams</figcaption></figure><p id="fc89">To add a Webhook, click on the dots beside the channel and click on <code>Connectors</code> .</p><figure id="ec15"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*tPlvvbOhxYeStQn8UUtRtQ.png"><figcaption>Add a Webhook</figcaption></figure><p id="5d4d">Configure an <code>Incoming Webhook</code>. Teams shows the Webhook URL once you click <code>Create</code>. Copy this URL in the next step.</p><figure id="e3ae"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*qezH6S6c1mgzAgUg6CView.png"><figcaption>Configure a Webhook</figcaption></figure><h2 id="8dd6">Connect GitHub Actions and Teams</h2><p id="bf45">Open the repository which should notify you on failed builds. Go to <code>Settings</code> and then to <code>Secrets</code> . Add a secret for <code>Actions</code> with the name <code>TEAMS_WEBHOOK</code>.</p><figure id="88e1"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*vR1JT9xuJQPr5iSNaouCnQ.png"><figcaption></figcaption></figure><h2 id="e5f7">Add the notification step to your workflow</h2><p id="2626">Open your <code>workflow.yml</code> and add the following step:</p> <figure id="8380"> <div> <div>

            <iframe class="gist-iframe" src="/gist/ablx/ee5699b5e3421d4d9645891735db3e6e.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
          </div>
        </div>
    </figure></iframe></div></div></figure><p id="d0ff">This step only runs if the pipeline failed before. It creates the payload for the Teams Webhook and executes a POST request.</p><p id="2bbd">You will get a notification in Teams for the next broken build:</p><figure id="9f56"><img src="https://cdn-images-1.readmedium.c

Options

om/v2/resize:fit:800/1*0jxPfhiUqs0xKJ1OmWMHeA.png"><figcaption>Notification for a failed build.</figcaption></figure><p id="d8e5">You can click on the button to open GitHub and see the broken pipeline. <b>That’s it! Now you can react faster to broken pipelines!</b></p><h2 id="1c84">Bonus: Teams payload in detail</h2><p id="f17b">Let’s inspect the payload:</p> <figure id="9228"> <div> <div>

            <iframe class="gist-iframe" src="/gist/ablx/75dae9dc6df1701cfca4d0800602222e.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
          </div>
        </div>
    </figure></iframe></div></div></figure><p id="fc12">Notice that we used <i>GitHub Actions environment variables</i> to add useful content to the message. You can see all available variables in the <a href="https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables">official documentation</a>.</p><p id="da33">The <code>themeColor</code> field handles the red bar in the notification. See the <a href="https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL">Webhook documentation</a> for more fields and examples.</p><p id="1d91">Want to get more out of Teams? Check out the following article:</p><div id="4f67" class="link-block">
      <a href="https://readmedium.com/react-faster-alertmanager-to-teams-fa888bcd7c01">
        <div>
          <div>
            <h2>How Alertmanager and Teams easily reduce incident response time proactive</h2>
            <div><h3>Get notifications from the Alertmanager to Microsoft Teams</h3></div>
            <div><p>medium.com</p></div>
          </div>
          <div>
            <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*kS9AnQKD5KRN7LHETv9MkQ.png)"></div>
          </div>
        </div>
      </a>
    </div></article></body>

How to get notified on Microsoft Teams if a build breaks!

Don’t be the guy who breaks a build right before end of work.

Photo by Dimitri Karastelev on Unsplash

It’s Friday, 4:30. You finished that important feature. You commit and push, the CI Server will deploy it to the test system. Fantastic! On Monday, you can show the client your work.

But what is this? Why is the pipeline red? Everything worked just seconds ago! You look at the build history. Damn! Jack broke the build hours ago and did not fix it! Way to go, Jack …

What now? While Jack enjoys his weekend, you fix his stupid code. Otherwise, the client will be mad at you on Monday.

Don’t be like Jack. Let the CI server notify you if a build breaks. Receive a Teams message on broken builds.

Configure Microsoft Teams

Add a channel to the team which should receive the notifications if you do not have one. Click on the dots beside the team name and choose Add Channel.

Add a new channel in Teams

To add a Webhook, click on the dots beside the channel and click on Connectors .

Add a Webhook

Configure an Incoming Webhook. Teams shows the Webhook URL once you click Create. Copy this URL in the next step.

Configure a Webhook

Connect GitHub Actions and Teams

Open the repository which should notify you on failed builds. Go to Settings and then to Secrets . Add a secret for Actions with the name TEAMS_WEBHOOK.

Add the notification step to your workflow

Open your workflow.yml and add the following step:

This step only runs if the pipeline failed before. It creates the payload for the Teams Webhook and executes a POST request.

You will get a notification in Teams for the next broken build:

Notification for a failed build.

You can click on the button to open GitHub and see the broken pipeline. That’s it! Now you can react faster to broken pipelines!

Bonus: Teams payload in detail

Let’s inspect the payload:

Notice that we used GitHub Actions environment variables to add useful content to the message. You can see all available variables in the official documentation.

The themeColor field handles the red bar in the notification. See the Webhook documentation for more fields and examples.

Want to get more out of Teams? Check out the following article:

Tech
Continous Integration
Github
DevOps
Teamwork
Recommended from ReadMedium