In Continuous Delivery, a faster feedback loop ensures quicker identification and resolution of bugs, audits, and approvals of the CI/CD pipeline stages in Spinnaker or other CD tools.
Microsoft Teams is a proprietary business communication and collaboration platform. DevOps teams often use MS Teams for workspace collaboration, communication, shared file storage, and application integration.
Why do we need to integrate Microsoft Teams in the Spinnaker CI/CD pipelines?
Every software delivery business needs a high-release cadence. Organizations need to have the proper insight, and approvals in place before releasing any applications into the production environments while using Spinnaker CI/CD pipelines. The release items need to undergo various testing and approvals processes before going into production and we need to know the execution status of the Spinnaker pipelines for proper “SignOff Approvals” from each and every release team member with approval authority. In order to have a smooth and continuous ongoing release process, we need to have a good feedback system like MS Teams.
Spinnaker CD (Continuous Delivery) makes life easier for the busy release teams in automating production releases, and with the capability to integrate with MS Teams, it automates approval of CI/CD pipeline stages. Thus, we can have a much easier release process with all the required approvals in place.
In this blog, we will discuss how Spinnaker can be integrated with MS Teams to instill a feedback mechanism in your CI/CD pipeline
Spinnaker 1.23 and later versions support sending notifications to Microsoft Teams using incoming Webhooks.
Enable Microsoft Teams for Spinnaker CI/CD pipelines
To enable Microsoft Teams to support, add the following statement to the ~/.hal/default/profiles/echo-local.yml file inside the Halyard pod.
When HA is enabled, create a ~/.hal/default/profiles/echo-worker-local.yml file inside the Halyard pod and add contents as shown below:
$ kubectl exec -it -n -- bash $ vim ~/.hal/default/profiles/echo-local.yml microsoftteams: enabled: true :wq! $ hal deploy apply
Create Microsoft Teams Incoming Webhook URL:
To create a custom Incoming Webhook in Teams, follow the instructions provided below:
1. Navigate to the Directory in MS Teams. Select (•••) “More Options” from the top navigation bar and select Add Channel and configure the same.
2. Select the channel you just created and then choose Connectors from the drop-down menu by clicking the (•••) icon and search for Incoming Webhook.
3. Select the Configure button, provide a name, and, optionally, upload an image avatar for your Webhook.
4. The dialog window will present a unique URL that will map the channel. Make sure that you copy and save the URL (You will need to provide it to the outside service).
5. Select the Done button. The Webhook will be available in the MS Teams channel.
Spinnaker will expect the URL to be in a specific format and it trimming off everything into a standard format URL as shown below
Modified URL for the above URL, as modified by Spinnaker:
Spinnaker expects URLs to be 35 characters long including ‘/ ‘ and all of the credentials come after that.
Example: https://outlook.office.com/webhook/ → 35 characters long and rest is credentials
URL modification is done by spinnaker and you can edit the URL but make sure it should have 35 characters including ‘/’ and all the credentials come after that.
Recommended Way: Copy the URL that you generated from MS Teams and paste it in Spinnaker as defined in Adding Webhook URL into the Spinnaker section below and start the job. Once the job is initiated, check the logs of echo-pod and there you will be able to see the following message:
$ kubectl logs -n
When HA is enabled, look for logs from <echo-worker-pod-name>
$ kubectl logs -n
2021-02-24 08:09:39.184 INFO 1 — [RxIoScheduler-3] .n.s.e.n.MicrosoftTeamsNotificationAgent : Building Microsoft Teams notification
2021-02-24 08:09:39.185 INFO 1 — [RxIoScheduler-3] .n.s.e.n.MicrosoftTeamsNotificationAgent : Sending Microsoft Teams notification
2021-02-24 08:09:39.192 INFO 1 — [RxIoScheduler-3] c.n.s.e.m.MicrosoftTeamsClient : —> HTTP POST
2021-02-24 08:09:39.326 ERROR 1 — [RxIoScheduler-3] .n.s.e.n. MicrosoftTeamsNotificationAgent: failed to send Microsoft teams message
Highlighted link from the above logs of the echo pod is the modified version of the provided Webhook URL as modified by Spinnaker. Copy that link and paste it in the MS Teams Webhook URL section in Spinnaker. That’s it, your MS Teams channel is now configured to receive Spinnaker pipeline execution notifications.
Steps to add Webhook URL in Spinnaker:
When configuring a Microsoft Teams notification, enter the full incoming Webhook URL in the MS Teams Webhook URL text box.
- Go to the Spinnaker application.
- You can define notifications at the Application level as well as the Pipeline level of the Application.
- Select the Application and go to the Pipeline for which notifications have to be sent.
- Navigate to the Notifications and select Add Notification Preference.
- Select Microsoft Teams under the dropdown “Notify via”.
- Paste the URL at the Teams Webhook URL section.
- Check the boxes, what you have to get notified w.r.t the pipeline/Application and update.
Once a job is initiated as defined then the notifications will be sent to the respective channel of Microsoft Teams.
From MS Teams you can navigate back to Spinnaker by clicking on View Execution and see the job status in Spinnaker.
So here in this blog, we have shown you how to integrate MS Teams with Spinnaker in order to generate custom notifications for different stages when the Spinnaker pipelines are executed. Now go ahead and give it a try yourself. If you face any difficulties feel free to comment or contact our support team.
The following articles can be interesting for you:
If you want to know more about Spinnaker or request a demonstration, please book a meeting with us.
OpsMx is a leading provider of Continuous Delivery solutions that help enterprises safely deliver software at scale and without any human intervention. We help engineering teams take the risk and manual effort out of releasing innovations at the speed of modern business. For additional information, contact us.