---
title: "Using Slack for Bamboo Status Reporting"
canonical: "https://support.appfire.com/space/SUPPORT/89133290/Using%20Slack%20for%20Bamboo%20Status%20Reporting"
format: markdown
---
# Summary

Make build and testing status visible for your teams and management so failures can be identified, discussed in team SUs, and handled in a timely manner. In our case, we have hundreds of plans across multiple Bamboo build servers and need to summarize the status of critical plans for different teams. We automatically report on a customized list of specific plans to specific teams in the team's Slack channel or notification channel depending on the need. The automation is run with Bamboo plans that specify timing and content.

This is done with the [Appfire Command Line Interface (CLI)](https://appfire.atlassian.net/wiki/spaces/ACLI) combining actions from the [Bamboo Command Line Interface (CLI)](https://appfire.atlassian.net/wiki/spaces/BCLI), the [CLI for Slack](https://appfire.atlassian.net/wiki/spaces/SLACKCLI), and the [CSV Command Line Interface (CLI)](https://appfire.atlassian.net/wiki/spaces/CSVCLI). Requires [Version 9.2](https://appfire.atlassian.net/wiki/spaces/SQL/pages/74323724) or higher.

### Action Links

- [getBuildReportList](https://appfire.atlassian.net/wiki/spaces/BCLI/pages/65929574) - Bamboo build report action
- [sendMessage](https://appfire.atlassian.net/wiki/spaces/SLACKCLI/pages/74025427) - Slack message
- [copyCsv](https://appfire.atlassian.net/wiki/spaces/CSVCLI/pages/68912245) - CSV report customization

# Details

| **Identify critical builds** | Focus on the most critical builds that need timely attention. There are multiple ways to specify what build plans should be included in the report.<br>1. Simple list of plan keys (fully qualified by project)
2. Simple list of plan keys in a specific project
3. Plans in a project with regex and other filtering criteria<br>```shell
acli examplegear.bamboo -a getBuildReportList --project EXAMPLE --list PLAN1,PLAN2,PLAN3 --field notState=UNKNOWN
```<br>> ✅ We report on the **last completed build** by filtering out currently running builds using: **--field notState=UNKNOWN** |
| --- | --- |
| **Choose columns to report** | Select the minimum columns needed. **getBuildReportList** already minimizes the columns reported. In this example, we want a very targeted report so we remove the first 3 columns.<br>```
... --columns -1,2,3
``` |
| **Choose a date format** | Specify a date format that best matches specific needs. We use a very concise format to minimize line length.<br>```
... --dateFormat "EEE HH:mm"
``` |
| **Modify data** | Format the data for the report. In this example, we are going to report as a text table, without wrapping, and with modified test result headings to minimize line length. This looks best in Slack.<br>```shell
acli csv -a copyCsv --sourceFile @temp --outputType text --headingAugments ",,Succ,Fail,Skip,Quar" --options screenwidth=999
``` |
| **Send to Slack** | Assumes you already have a Slack token for your Slack instance, acli configured to use the token, and access granted to allow the CLI to send to your channel - see [Access Tokens](https://appfire.atlassian.net/wiki/spaces/SLACKCLI/pages/74023387) and related information for [CLI for Slack](https://appfire.atlassian.net/wiki/spaces/SLACKCLI).<br>We are using markdown code format to get fixed width lines with active links to click on the URL to quickly get to a build with a problem.<br>```shell
slack -a sendMessage --channel ${bamboo.channel} -f @temp --options markdown=code
``` |
| **Full example** | We use a Bamboo plan with a script task. This assumes **acli** is on the path and configured appropriately to access the servers needed. This example uses linux style escaping. We use the CLI temp file for automatically handling of file output<br>##### **Example**<br>```shell
acli -a run \
  -i "bamboo.examplegear -a getBuildReportList --project EXAMPLE --list PLAN1,PLAN2,PLAN3 -f @temp --field notState=UNKNOWN --dateFormat \"EEE HH:mm\" --columns -1,2,3" \
  -i "csv -a convertCsv --sourceFile @temp -f @temp --outputType text --headingAugments \",,Succ,Fail,Skip,Quar\" --options screenwidth=999 " \
  -i "slack -a sendMessage --channel ${bamboo.channel} -f @temp --options markdown=code "
``` |
| **Results** | ```plaintext
 Completed  State       Succ  Fail  Skip  Quar  URL                                                                    
 Wed 08:36  SUCCESSFUL     0     0     0     0  https://bamboo.examplegear.com/browse/EXAMPLE-PLAN1-30
 Tue 19:06  SUCCESSFUL    76     0     0     0  https://bamboo.examplegear.com/browse/EXAMPLE-PLAN2-31
 Wed 08:35  SUCCESSFUL   996     0   119     7  https://bamboo.examplegear.com/browse/EXAMPLE-PLAN3-32
```<br>> ✅ If lines get wrapped in Slack, use **control or cmd -** (minus) to scale back font size.<br>> ✅ **Managers - what to watch**
> ✅ 
> ✅ 1. **Completed** - when was the last time this was run? Critical builds should be run daily or at least once a week
> ✅ 2. **State** - anything other than SUCCESSFUL needs someone to investigate and fix before next run
> ✅ 3. **Succ** - 0 means no tests recorded - is that expected?
> ✅ 4. **Quar** - number of quarantined tests. Failing tests being ignored for a good reason? Can successful tests be removed from quarantine? |

# More Examples and Techniques

| **Append data from other projects or servers** | ##### **Example**<br>```shell
acli -a run \
  -i "bamboo.examplegear  -a getBuildReportList --project EXAMPLE --list PLAN1,PLAN2,PLAN3 -f @temp --field notState=UNKNOWN --dateFormat \"EEE HH:mm\" --columns -1,2,3" \
  -i "bamboo2.examplegear -a getBuildReportList --project EXAMPLE2 --regex PLAN.* -f @temp --append --field notState=UNKNOWN --dateFormat \"EEE HH:mm\" --columns -1,2,3" \
  -i "csv -a convertCsv --sourceFile @temp -f @temp --outputType text --headingAugments \",,Succ,Fail,Skip,Quar\" --options screenwidth=999 " \
  -i "slack -a sendMessage --channel ${bamboo.channel} -f @temp --options markdown=code "
``` |
| --- | --- |
| **Show where report came from** | Add the following to your script if you are running it from Bamboo<br>```shell
# Show where the message comes from - this build! This makes it easy to re-run the report after the problems have been fixed:    
acli slack -a sendMessage --channel ${bamboo.channel} --content '[{"type": "context","elements": [{"type": "mrkdwn","text": "Reported from ${bamboo.resultsUrl}"}]}]'
```<br>Result<br>```plaintext
Reported from https://bamboo.examplegear.com/browse/ADMIN-BUILDSTATUS-JOB1-3

``` |
| **Use script variables** | When running from a Bamboo using a script, you can use simple scripting to help standardize the acli action across multiple builds for similar reports. This highlights the key differences and makes it easier to read.<br>##### **Example**<br>```shell
#!/bin/bash -x
set -e  # error on failure

site=bamboo.examplegear
list=EXAMPLE-NIGHTLY,EXAMPLE-JIRAACCESSCHECK,EXAMPLE2-UNKNOWNLINKS,EXAMPLE2-BUILDSTATUS,EXAMPLE2-DEVOPS


acli -a run \
  -i "${site} -a getBuildReportList --list ${list} -f @temp --field notState=UNKNOWN --dateFormat \"EEE HH:mm\" --columns -1,2,3" \
  -i "csv -a convertCsv --sourceFile @temp -f @temp --outputType text --headingAugments \",,Succ,Fail,Skip,Quar\" --options screenwidth=999 " \
  -i "slack -a sendMessage --channel ${bamboo.channel} -f @temp --options markdown=code "


# Show where the message comes from - this build! This makes it easy to re-run the report after the problems have been fixed:
acli slack -a sendMessage --channel ${bamboo.channel} --content '[{"type": "context","elements": [{"type": "mrkdwn","text": "Reported from ${bamboo.resultsUrl}"}]}]'
``` |