Support a list of checkboxes in block fields

Originally posted on github: https://github.com/buildkite/feedback/issues/280

At the moment, if you want people to choose from a list of items with custom block fields it’s very difficult. The common way people are doing it is pre-filling a textarea, and then asking people to remove any lines from the text area. And then using that value, split on newline, as the chosen options. This is error prone and a bit clunky.

A better way might be a way for people to use an array of checkbox options in the block form…

If you we had a new checkbox option, and someone used the key field of servers-to-deploy , and someone unblocked it selecting 2 of the 10 available options, the meta-data keys/values could be:

servers-to-deploy-count=2
servers-to-deploy-1=The First Server
servers-to-deploy-2=The Second Server

To use those values, you could iterate over them using bash:

if buildkite-agent meta-data exists “servers-to-deploy-count”; then for i in seq 1 $(buildkite-agent meta-data get "servers-to-deploy-count"); do echo “Deploying server (buildkite-agent meta-data get "servers-to-deploy-{i}”)…" done fi

If nothing is selected, then there should be no servers-to-deploy-count key.

Good news: we’ve just added support for this :tada:

1 Like