Integrations
TeamCity
Overview
This document provides a detailed guide to integrating TeamCity with Callgoose SQIBS for real-time Incident Management, Incident Auto Remediation, Event-Driven Automation, and other automation purposes. The integration enables automatic creation, updating, and resolution of incidents in Callgoose SQIBS based on build and deployment notifications triggered in TeamCity. The guide includes steps for setting up notifications in TeamCity, configuring webhook notifications, creating API filters in Callgoose SQIBS, and troubleshooting.
Prerequisites
- TeamCity Account: Access to TeamCity for setting up notifications.
- Callgoose SQIBS Account: With valid privileges to set up API filters and receive notifications.
- Webhook/API Endpoint: Available in Callgoose SQIBS to receive alerts from TeamCity.
1. Obtain API Token and Endpoint Details
To integrate with Callgoose SQIBS, you first need to obtain an API token and find the API endpoint details.
- Generate an API Token:
- Follow the guide on How to Create API Token in Callgoose SQIBS. API Token Documentation
- Find the API Endpoint:
- Refer to the Callgoose SQIBS API Endpoint Documentation to get the endpoint details where the JSON payloads from TeamCity will be sent. API Endpoint Documentation
2. Debugging and Troubleshooting
You can enable debugging in the API tokens used with TeamCity notifications for troubleshooting purposes.
- Enable Debugging:
- You can update the debug value when adding or updating an API token.
- When API tracking is enabled, logs are stored in the API log section for your review. The debugging option will automatically disable after 48 hours.
- When API tracking is turned off, no logs are saved in the API log.
- Using API Log for Troubleshooting:
- The API log provides detailed information on all API calls made to Callgoose SQIBS.
- You can check the JSON values in each API log entry for troubleshooting purposes.
- Use the information in the API log to create or refine API filters to ensure incidents are created correctly based on the API payloads received.
- Callgoose SQIBS creates incidents according to your API filter configuration, giving you full control over how alerts from different services trigger incidents and alerts for your support team or automation processes.
3. Configuring TeamCity to Send JSON Payloads
To configure TeamCity to generate the JSON payloads similar to the examples provided, follow the steps outlined below. These steps will guide you through setting up the necessary build and deployment notifications within TeamCity to ensure that the JSON payloads match those expected by Callgoose SQIBS.
3.1 Setting Up Notifications in TeamCity
To configure notifications in TeamCity and generate the required JSON payloads, follow the steps below:
- Log in to the TeamCity Console
- Access the TeamCity platform using your credentials. If you haven’t created a project yet, do so by referring to the relevant TeamCity documentation.
- Connect Your Project
- After creating or connecting your project, navigate to the homepage and click on your project.
- Enable Webhooks
- Click Edit Project to configure your project.
- Navigate to the Parameters section.
- Click on Add New Parameter.
- Enable Webhook Functionality
- In the Name field, enter teamcity.internal.webhooks.enable.
- Leave the Kind and Value Type fields unchanged.
- In the Value field, enter true.
- Click Save.
- Specify Webhook Events
- Click Add New Parameter again.
- In the Name field, enter teamcity.internal.webhooks.events.
- In the Value field, specify the events you want notifications for, e.g., BUILD_FINISHED;BUILD_INTERRUPTED. You can add other events by referring to the TeamCity Webhooks.
- Click Save.
- Configure Webhook URL
- Click Add New Parameter.
- In the Name field, enter teamcity.internal.webhooks.url.
- In the Value field, provide the webhook URL provided by Callgoose SQIBS. Final endpoint URL may change, refer API endpoint for more details.
- Click Save.
Now, the webhook is connected.
3.2 Configuring Custom Webhook Payload
If you want to customize the payload structure to include specific fields in the JSON, follow these steps:
- Customize the Payload Format
- Click Add New Parameter.
- In the Name field, provide the following format: teamcity.internal.webhooks.{event_name}.fields, replacing {event_name} with the specific event you want to customize. For example, for build completion events, use BUILD_FINISHED.
- Define the Payload Fields
- In the Value field, define the structure for the payload. For example, for build events, you could use: fields=buildTypeId,number,status,branchName,buildType(projectName,projectId),triggered(user(username,name))
- Click Save.
- By following this process, you can set up webhook notifications in TeamCity and customize the payload structure according to your needs.
3.3 Finalizing and Testing
- Validate the Integration:
- Trigger a build or deployment manually if possible to verify that the correct JSON payload is sent to Callgoose SQIBS.
- Resolve any issues or failures in the build or deployment to ensure that the resolved state payload is also correctly sent and processed.
4. Configuring Callgoose SQIBS
4.1 Create API Filters in Callgoose SQIBS
To correctly map incidents from the TeamCity notifications, you need to create API filters based on the JSON payloads received.
4.1.1 Example JSON Payloads from TeamCity
Build Failed (status: "FAILURE")
json { "eventType": "BUILD_FINISHED", "payload": { "buildTypeId": "TestingWebhookUpdate4_Build", "number": "32", "status": "FAILURE", "branchName": "main", "statusText": "Python error: SyntaxError", "buildType": { "projectName": "Testing Webhook Update 4", "projectId": "TestingWebhookUpdate4" }, "triggered": { "user": { "username": "****-admin", "name": "****" } } } }
Build Successful (status: "SUCCESS")
json { "eventType": "BUILD_FINISHED", "payload": { "buildTypeId": "TestingWebhookUpdate4_Build", "number": "34", "status": "SUCCESS", "branchName": "main", "statusText": "Success", "buildType": { "projectName": "Testing Webhook Update 4", "projectId": "TestingWebhookUpdate4" }, "triggered": { "user": { "username": "****-admin", "name": "****" } } } }
4.2 Configuring API Filters
4.2.1 Integration Templates
If you see a TeamCity integration template in the "Select Integration Template" dropdown in the API filter settings, you can use it to automatically add the necessary Trigger and Resolve filters along with other values. The values added by the template can be modified to customize the integration according to your requirements.
4.2.2 Manually Add/Edit the Filter
- Trigger Filter (For Creating Incidents):
- Payload JSON Key: "payload"."status"
- Key Value Contains: [FAILURE, UNKNOWN]
- Map Incident With: "payload"."buildTypeId"
- This corresponds to the unique payload.buildTypeId from the TeamCity payload.
- Incident Title From: "eventType"
- This will use the Event Type as the incident title in Callgoose SQIBS.
- Incident Description From: Leave this empty unless you want to use a specific key-value from the JSON payload. If a key is entered, only the value for that key will be used as the Incident Description instead of the full JSON. By default, the Incident Description will include the full JSON values.
- Example: If you use the "statusText" key in the Incident Description From field, the incident description will be the value of the "statusText" key. In the example JSON payload provided earlier, this would result in a description like "Python error: SyntaxError".
- Resolve Filter (For Resolving Incidents):
- Payload JSON Key: "payload"."status"
- Key Value Contains: [SUCCESS]
- Incident Mapped With: "payload"."buildTypeId"
- This ensures the incident tied to the specific payload.buildTypeId is resolved when the build status returns to success.
Refer to the API Filter Instructions and FAQ for more details.
4.3 Finalizing Setup
- Save the API Filters:
- Ensure that the filters are correctly configured and saved in Callgoose SQIBS.
- Double-check that all key mappings, incident titles, and descriptions are correctly aligned with the payload structure sent by TeamCity.
5. Testing and Validation
5.1 Triggering Build/Deployment Alerts
- Simulate a Build Failure:
- Introduce an error in the code or configuration that triggers a build failure in TeamCity.
- Verify that an incident is created in Callgoose SQIBS with the correct information, including the project name, branch, and error description.
- Simulate a Successful Build:
- Fix the error and trigger a successful build.
- Verify that the incident in Callgoose SQIBS is automatically marked as resolved, and ensure that the correct information is reflected in the incident resolution.
5.2 Resolving Alerts
- Acknowledge and Resolve the Alert:
- Once the issue is resolved in TeamCity (e.g., the build is successful), verify that the incident in Callgoose SQIBS is automatically marked as resolved.
6. Security Considerations
- API Security: Ensure that the Callgoose SQIBS API endpoint is correctly configured and that the API token is securely stored and used.
- TeamCity Permissions: Confirm that the webhook in TeamCity has appropriate permissions to send alerts and data to Callgoose SQIBS.
7. Troubleshooting
- No Incident Created: If no incident is created, verify that the webhook URL in TeamCity is correct and that the JSON payload structure matches the API filters configured in Callgoose SQIBS.
- Incident Not Resolved: Ensure that the resolve filter in Callgoose SQIBS is correctly configured and that the JSON payload sent by TeamCity matches the expected structure.
8. Conclusion
This guide provides a comprehensive overview of how to integrate TeamCity with Callgoose SQIBS for effective incident management. By following the steps outlined, you can ensure that build and deployment notifications from TeamCity are automatically reflected as incidents in Callgoose SQIBS, with proper resolution tracking when the issues are resolved.
For further customization or advanced use cases, refer to the official documentation for both TeamCity and Callgoose SQIBS:
- TeamCity Documentation
- Callgoose SQIBS API Token Documentation
- Callgoose SQIBS API Endpoint Documentation
- API Filter Instructions and FAQ
- How to Send API
This documentation will guide you through the integration process, ensuring that your incidents are managed effectively within Callgoose SQIBS based on real-time notifications from TeamCity.