Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Expose bamboo notification plugin to yaml

I'm trying to fond information on how to expose/read my plugin configuration to/from yaml files (bamboo-spec). 


It this at all possible from a custom plugin ?

1 answer

1 vote
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Jan 09, 2022

Hello @Mathieu MARACHE ,

There's no public documentation with specs API support for plugin.

Below are few snippets which can give you some direction. Also you can find more sample at Bamboo source code which you can find at if have any Bamboo license


Exporter class

import com.atlassian.bamboo.notification.NotificationRecipientExporter;
import com.atlassian.bamboo.slack.yaml.YamlParser;
import com.atlassian.bamboo.specs.api.model.notification.AnyNotificationRecipientProperties;
import com.atlassian.bamboo.specs.api.model.notification.NotificationRecipientProperties;
import com.atlassian.bamboo.specs.yaml.Node;
import com.atlassian.bamboo.util.Narrow;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;

public class SlackNotificationRecipientExporter implements NotificationRecipientExporter {
public NotificationRecipient toSpecsEntity(@NotNull String recipientKey, @NotNull String recipientData) {
return new AnyNotificationRecipient(new AtlassianModule(SlackNotificationRecipient.PLUGIN_KEY))

public String importNotificationRecipient(NotificationRecipientProperties recipient) {
if (recipient instanceof AnyNotificationRecipientProperties
&& Objects.equals(SlackNotificationRecipient.PLUGIN_KEY, recipient.getAtlassianPlugin().getCompleteModuleKey())) {
return ((AnyNotificationRecipientProperties) recipient).getRecipientString();
throw new IllegalStateException("Don't know how to import notification type class: " + recipient.getClass().getName());

public fromYaml(Node node) {
return YamlParser.parse(node);

public Node toYaml(NotificationRecipientProperties recipient) {
final AnyNotificationRecipientProperties properties = Narrow.downTo(recipient,
if (properties != null) {
final SlackConfig config = SlackConfig.parse(properties.getRecipientString());
if (config != null) {
return YamlParser.generate(config);
return null;


<notificationRecipient key="recipient.slack" name="Slack Recipient" class="com.atlassian.bamboo.slack.SlackNotificationRecipient" weight="10">
<exporter class="com.atlassian.bamboo.slack.SlackNotificationRecipientExporter" />


import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.Nullable;

public class SlackConfig {
private final String webhookUrl;
private final String channel;
private final String iconUrl;
private final String botName;

private SlackConfig(String webhookUrl, String channel, String iconUrl, String botName) {
this.webhookUrl = webhookUrl; = channel;
this.iconUrl = iconUrl;
this.botName = botName;

* Parse config line.
* @param configurationData store line
* @return parsed config
public static SlackConfig parse(@Nullable String configurationData) {
String webhookUrl = "";
String channel = "";
String iconUrl = "";
String botName = "";
if (StringUtils.isNotBlank(configurationData)) {
String delimiter = "\\|";

String[] configValues = configurationData.split(delimiter);

if (configValues.length > 0) {
webhookUrl = configValues[0];
if (configValues.length > 1) {
channel = configValues[1];
if (configValues.length > 2) {
iconUrl = configValues[2];
if (configValues.length > 3) {
botName = configValues[3];
return new SlackConfig(webhookUrl, channel, iconUrl, botName);
} else {
return null;

public String getWebhookUrl() {
return webhookUrl;

public String getChannel() {
return channel;

public String getIconUrl() {
return iconUrl;

public String getBotName() {
return botName;


import com.atlassian.bamboo.slack.SlackConfig;
import com.atlassian.bamboo.slack.SlackNotificationRecipient;
import com.atlassian.bamboo.specs.api.validators.common.ValidationContext;
import com.atlassian.bamboo.specs.yaml.BambooYamlParserUtils;
import com.atlassian.bamboo.specs.yaml.MapNode;
import com.atlassian.bamboo.specs.yaml.Node;
import com.atlassian.bamboo.specs.yaml.StringNode;
import com.atlassian.bamboo.util.Narrow;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;

public class YamlParser {
private static final String SLACK_ATLASSIAN = "slack-atlassian";
private static final String WEBHOOK_URL = "webhook-url";
private static final String CHANNEL = "channel";
private static final String ICON_URL = "icon-url";
private static final String BOT_NAME = "bot-name";

public static NotificationRecipient<?, ?> parse(@NotNull final Node recipientsNode) {
MapNode mapNode = Narrow.downTo(recipientsNode, MapNode.class);
if (mapNode != null && mapNode.getOptionalNode(SLACK_ATLASSIAN).isPresent()) {
final MapNode slackNode = mapNode.getMap(SLACK_ATLASSIAN);
String webhookUrl = slackNode.getString(WEBHOOK_URL).get();
String channel = slackNode.getString(CHANNEL).get();
String iconUrl = slackNode.getOptionalString(ICON_URL).map(StringNode::get).orElse("");
String botName = slackNode.getOptionalString(BOT_NAME).map(StringNode::get).orElse("");
return new AnyNotificationRecipient(new AtlassianModule(SlackNotificationRecipient.PLUGIN_KEY))
.recipientString(SlackNotificationRecipient.toConfigString(webhookUrl, channel, iconUrl, botName));
} else {
return null;

public static Node generate(@NotNull SlackConfig slackConfig) {
final Map<String, Object> result = new LinkedHashMap<>();
final Map<String, String> config = new LinkedHashMap<>();
putIfNotEmpty(config, WEBHOOK_URL, slackConfig.getWebhookUrl());
putIfNotEmpty(config, CHANNEL, slackConfig.getChannel());
putIfNotEmpty(config, ICON_URL, slackConfig.getIconUrl());
putIfNotEmpty(config, BOT_NAME, slackConfig.getBotName());
result.put(SLACK_ATLASSIAN, config);
return BambooYamlParserUtils.asNode(result, ValidationContext.of(SLACK_ATLASSIAN));

private static void putIfNotEmpty(Map<String, String> container, String key, String value) {
if (StringUtils.isNotBlank(value)) {
container.put(key, value);



Hi Alexey, thanks for such a detailed answer !

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events