How to show multiple changes in a Teams Card template?

I’d like to show who committed / and their commit comments in the Build Broken template Card for MS Teams.

In the email notification template, I can do it like this to get all the changes listed:

Repository  / Branch / User / Issues / Comment
{% for change in ChangeSets %}
{{ change.RepositoryName }} / {{ change.Branch }} / {{ change.RepositoryUserName }} / {% for issue in change.Issues %}{% if forloop.last == true %}{{ issue.Name }}{% else %}{{ issue.Name }}, {% endif %}{% endfor %} / {{ change.Comment }}
{% endfor %}

but how is this done in a Teams Card template?

Hi Lars,

You can add a “text” property under a “section” in the template.

e.g.

{
	"@type": "MessageCard",
	"@context": "http://schema.org/extensions",
	"themeColor": "#548dd4",
	"summary": "Build has status of {{Name}}",
	"sections": [{
		"activityTitle": "![Continua CI](https://i.finalbuilder.com/images/ci-c-3232.png)Build **{{Version}}** has a status of **{{Name}}**",
		"activitySubtitle": "from configuration **{{Project.Name}}:{{ConfigName}}**",
		"activityImage": "https://i.finalbuilder.com/images/ci-c-3232.png",
		"facts": [{
			"name": "Status",
			"value": "{{Name}}"
		}, {
			"name": "Started by",
			"value": "{{StartedBy}}"
		}],
		"markdown": true,
        "text": "| **Repository** |  **Branch**  |  **User** | **Issues** | **Comment** |
{% for change in ChangeSets %}
| {{ change.RepositoryName }} | {{ change.Branch }} | {{ change.RepositoryUserName }} | {% for issue in change.Issues %}{% if forloop.last == true %}{{ issue.Name }}{% else %}{{ issue.Name }}, {% endif %}{% endfor %} | {{ change.Comment }} |
{% endfor %}"
	}],
	"potentialAction": [{
		"@type": "OpenUri",
		"name": "View Build",
		"targets": [
		{ "os": "default", "uri": "{{BuildUrl}}" }
		]
	}, {
		"@type": "OpenUri",
		"name": "View Configuration",
		"targets": [
		{ "os": "default", "uri": "{{ConfigurationUrl}}" }
		]
	}, {
		"@type": "OpenUri",
		"name": "View Project",
		"targets": [
		{ "os": "default", "uri": "{{ProjectUrl}}" }
		]
	}]
}

The text property supports a subset of markdown - see Card formatting so it’s not really possible to show an aligned table of changesets. You can however add a “section” for each changeset.
e.g.

{
	"@type": "MessageCard",
	"@context": "http://schema.org/extensions",
	"themeColor": "#548dd4",
	"summary": "Build has status of {{Name}}",
	"sections": [{
		"activityTitle": "![Continua CI](https://i.finalbuilder.com/images/ci-c-3232.png)Build **{{Version}}** has a status of **{{Name}}**",
		"activitySubtitle": "from configuration **{{Project.Name}}:{{ConfigName}}**",
		"activityImage": "https://i.finalbuilder.com/images/ci-c-3232.png",
		"facts": [{
			"name": "Status",
			"value": "{{Name}}"
		}, {
			"name": "Started by",
			"value": "{{StartedBy}}"
		}],
		"markdown": true
	},
    {
		"activityTitle": "Changesets"
	}
{% for change in ChangeSets %}
  , {
        "activitySubtitle": "Revision {{ change.RepositoryChangeId}}",
		"facts": [{
			"name": "Repository",
			"value": "{{change.RepositoryName}}"
		}, {
			"name": "Branch",
			"value": "{{change.Branch}} "
		}, {
			"name": "User",
			"value": "{{change.RepositoryUserName}} "
		}, {
			"name": "Issues",
			"value": "{% for issue in change.Issues %}{% if forloop.last == true %}{{ issue.Name }}{% else %}{{ issue.Name }}, {% endif %}{% endfor %}"
		}, {
			"name": "Comment",
			"value": "{{change.Comment }}"
		}]
     }
{% endfor %}
    ],
	"potentialAction": [{
		"@type": "OpenUri",
		"name": "View Build",
		"targets": [
		{ "os": "default", "uri": "{{BuildUrl}}" }
		]
	}, {
		"@type": "OpenUri",
		"name": "View Configuration",
		"targets": [
		{ "os": "default", "uri": "{{ConfigurationUrl}}" }
		]
	}, {
		"@type": "OpenUri",
		"name": "View Project",
		"targets": [
		{ "os": "default", "uri": "{{ProjectUrl}}" }
		]
	}]
}

See message card reference for full details of the json format for Teams cards.

1 Like