@simplysf/simply-cicd 0.15.1 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -37
- package/lib/commands/simply/cicd/notify/build.d.ts +28 -0
- package/lib/commands/simply/cicd/notify/build.js +136 -0
- package/lib/commands/simply/cicd/notify/build.js.map +1 -0
- package/lib/common/notify/buildNotification.d.ts +53 -0
- package/lib/common/notify/buildNotification.js +176 -0
- package/lib/common/notify/buildNotification.js.map +1 -0
- package/lib/common/notify/templates.d.ts +2 -0
- package/lib/common/notify/templates.js +21 -0
- package/lib/common/notify/templates.js.map +1 -1
- package/messages/simply.cicd.notify.build.md +83 -0
- package/messages/simply.cicd.notify.teams.md +1 -1
- package/oclif.manifest.json +1442 -1257
- package/package.json +4 -3
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { promises as fs } from 'node:fs';
|
|
17
|
+
import { execa } from 'execa';
|
|
18
|
+
import { isSubscriberPackageVersionId, readSfdxProject } from '@simplysf/simply-core';
|
|
19
|
+
import { createAlmProvider } from '@simplysf/simply-cicd-core';
|
|
20
|
+
import { VersionTagFormat } from '../build/versionTagFormat.js';
|
|
21
|
+
import { logger } from '../logger.js';
|
|
22
|
+
import { NOT_AVAILABLE, renderIssuesFromCommitLog } from './getCommitStories.js';
|
|
23
|
+
import { renderNotifyTemplate } from './renderTemplate.js';
|
|
24
|
+
import { sendNotification } from './sendNotification.js';
|
|
25
|
+
/** The file `build create-package-version` writes the new version's `04t` ID to. */
|
|
26
|
+
export const SUBSCRIBER_PACKAGE_VERSION_ID_FILE = 'subscriberPackageVersionId.env';
|
|
27
|
+
/**
|
|
28
|
+
* The `04t` ID of a package version created in this job: the explicit value if given, otherwise the
|
|
29
|
+
* one `build create-package-version` wrote to {@link SUBSCRIBER_PACKAGE_VERSION_ID_FILE}. `undefined`
|
|
30
|
+
* when the job created none.
|
|
31
|
+
*/
|
|
32
|
+
export async function resolveSubscriberPackageVersionId(explicit) {
|
|
33
|
+
if (explicit) {
|
|
34
|
+
return explicit;
|
|
35
|
+
}
|
|
36
|
+
let content;
|
|
37
|
+
try {
|
|
38
|
+
content = await fs.readFile(SUBSCRIBER_PACKAGE_VERSION_ID_FILE, 'utf8');
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const value = /^SUBSCRIBER_PACKAGE_VERSION_ID=(?<id>\S+)\s*$/m.exec(content)?.groups?.id;
|
|
44
|
+
return value && isSubscriberPackageVersionId(value) ? value : undefined;
|
|
45
|
+
}
|
|
46
|
+
/** Fetches the tags, and the full history when the CI clone is shallow, so tags can be described and diffed. */
|
|
47
|
+
export async function fetchVersionHistory() {
|
|
48
|
+
const { stdout } = await execa('git', ['rev-parse', '--is-shallow-repository']);
|
|
49
|
+
const unshallow = stdout.trim() === 'true' ? ['--unshallow'] : [];
|
|
50
|
+
await execa('git', ['fetch', ...unshallow, '--tags', '--quiet']);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The tag at `HEAD` that `build create-package-version` annotated with `subscriberPackageVersionId`.
|
|
54
|
+
* Matching on the annotation rather than the name works for any version tag format or suffix.
|
|
55
|
+
*/
|
|
56
|
+
export async function findPackageVersionTag(subscriberPackageVersionId) {
|
|
57
|
+
const { stdout } = await execa('git', [
|
|
58
|
+
'tag',
|
|
59
|
+
'--points-at',
|
|
60
|
+
'HEAD',
|
|
61
|
+
'--format=%(refname:short)%09%(contents:subject)',
|
|
62
|
+
]);
|
|
63
|
+
return stdout
|
|
64
|
+
.split(/\r?\n/)
|
|
65
|
+
.map((line) => line.split('\t'))
|
|
66
|
+
.find(([, subject]) => subject?.trim() === subscriberPackageVersionId)?.[0];
|
|
67
|
+
}
|
|
68
|
+
/** The nearest version tag, in the project's format, before `versionTag`. `undefined` for a package's first version. */
|
|
69
|
+
export async function findPreviousVersionTag(versionTag) {
|
|
70
|
+
const project = await readSfdxProject().catch(() => undefined);
|
|
71
|
+
const glob = VersionTagFormat.fromProject(project).matchPattern();
|
|
72
|
+
try {
|
|
73
|
+
const { stdout } = await execa('git', ['describe', '--tags', '--abbrev=0', '--match', glob, `${versionTag}^`]);
|
|
74
|
+
return stdout.trim() || undefined;
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Resolves the new version's tag, the previous version's tag, and the issue references in between.
|
|
82
|
+
* Never throws: anything it can't resolve comes back as `N/A`, because a notification shouldn't be
|
|
83
|
+
* what fails a build.
|
|
84
|
+
*/
|
|
85
|
+
export async function getPackageVersionHistory(subscriberPackageVersionId, options) {
|
|
86
|
+
const history = { ...NOT_AVAILABLE, versionTag: 'N/A', previousVersionTag: 'N/A' };
|
|
87
|
+
try {
|
|
88
|
+
await fetchVersionHistory();
|
|
89
|
+
const versionTag = await findPackageVersionTag(subscriberPackageVersionId);
|
|
90
|
+
if (!versionTag) {
|
|
91
|
+
logger.warn(`No tag at HEAD is annotated with ${subscriberPackageVersionId}.`);
|
|
92
|
+
return history;
|
|
93
|
+
}
|
|
94
|
+
history.versionTag = versionTag;
|
|
95
|
+
const previousVersionTag = await findPreviousVersionTag(versionTag);
|
|
96
|
+
if (!previousVersionTag) {
|
|
97
|
+
logger.info(`No version tag before ${versionTag}. Skipping stories.`);
|
|
98
|
+
return history;
|
|
99
|
+
}
|
|
100
|
+
history.previousVersionTag = previousVersionTag;
|
|
101
|
+
const { stdout: commits } = await execa('git', ['log', '--pretty=oneline', `${previousVersionTag}..${versionTag}`]);
|
|
102
|
+
if (commits) {
|
|
103
|
+
Object.assign(history, renderIssuesFromCommitLog(commits, options.almProjectKey, {
|
|
104
|
+
almBaseUrl: options.almBaseUrl,
|
|
105
|
+
almProvider: createAlmProvider(options.almProvider ?? 'jira'),
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
logger.warn(`Could not resolve package version history: ${error.message}`);
|
|
111
|
+
if (options.debug) {
|
|
112
|
+
logger.error(String(error));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return history;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Posts a failure card for a failed build job, or a package version card for a successful job that
|
|
119
|
+
* created a package version. Any other job result sends nothing.
|
|
120
|
+
*/
|
|
121
|
+
export async function sendBuildNotification(options) {
|
|
122
|
+
const { ciJobStatus } = options;
|
|
123
|
+
const templateData = {
|
|
124
|
+
refName: options.ciCommitRefName,
|
|
125
|
+
pipelineUrl: options.ciPipelineUrl,
|
|
126
|
+
pipelineId: options.ciPipelineId,
|
|
127
|
+
projectTitle: options.ciProjectTitle,
|
|
128
|
+
jobName: options.ciJobName,
|
|
129
|
+
stage: options.ciJobStage,
|
|
130
|
+
stories: 'N/A',
|
|
131
|
+
storiesLinked: 'N/A',
|
|
132
|
+
};
|
|
133
|
+
let templateName;
|
|
134
|
+
if (ciJobStatus === 'failed') {
|
|
135
|
+
templateName = 'build-failure-notification';
|
|
136
|
+
}
|
|
137
|
+
else if (ciJobStatus === 'success') {
|
|
138
|
+
const subscriberPackageVersionId = await resolveSubscriberPackageVersionId(options.subscriberPackageVersionId);
|
|
139
|
+
if (!subscriberPackageVersionId) {
|
|
140
|
+
logger.info('No package version was created in this job. Skipping notification.');
|
|
141
|
+
return { sent: false };
|
|
142
|
+
}
|
|
143
|
+
templateName = 'build-package-version-notification';
|
|
144
|
+
logger.info(`Gathering stories for package version ${subscriberPackageVersionId}...`);
|
|
145
|
+
const history = await getPackageVersionHistory(subscriberPackageVersionId, options);
|
|
146
|
+
Object.assign(templateData, {
|
|
147
|
+
subscriberPackageVersionId,
|
|
148
|
+
packageVersion: history.versionTag,
|
|
149
|
+
packageVersionPrevious: history.previousVersionTag,
|
|
150
|
+
stories: history.stories,
|
|
151
|
+
storiesLinked: history.storiesWithUrl,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
logger.info(`No notification logic for job status: ${ciJobStatus ?? 'unknown'}`);
|
|
156
|
+
return { sent: false };
|
|
157
|
+
}
|
|
158
|
+
const payload = {
|
|
159
|
+
content: renderNotifyTemplate(templateName, templateData),
|
|
160
|
+
refName: options.ciCommitRefName,
|
|
161
|
+
pipelineId: options.ciPipelineId,
|
|
162
|
+
pipelineUrl: options.ciPipelineUrl,
|
|
163
|
+
projectTitle: options.ciProjectTitle,
|
|
164
|
+
jobName: options.ciJobName,
|
|
165
|
+
jobStage: options.ciJobStage,
|
|
166
|
+
jobStatus: ciJobStatus,
|
|
167
|
+
stories: templateData.stories,
|
|
168
|
+
storiesLinked: templateData.storiesLinked,
|
|
169
|
+
packageVersionPrevious: templateData.packageVersionPrevious,
|
|
170
|
+
packageVersion: templateData.packageVersion,
|
|
171
|
+
subscriberPackageVersionId: templateData.subscriberPackageVersionId,
|
|
172
|
+
};
|
|
173
|
+
await sendNotification(options.teamsWebhookUrl, payload);
|
|
174
|
+
return { sent: true };
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=buildNotification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildNotification.js","sourceRoot":"","sources":["../../../src/common/notify/build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|
2
2
|
export declare const NOTIFY_TEMPLATES: {
|
|
3
|
+
readonly 'build-failure-notification': "<table>\n <tr><th colspan=\"3\" style=\"color: white; background-color: darkred;\">{{projectTitle}}: Failed Build</th></tr>\n <tr><th colspan=\"3\" style=\"color: white; background-color: grey;\">Job: {{jobName}} (Stage:\n {{stage}})</th></tr>\n <tr><td>Branch</td><td colspan=\"2\">Pipeline</td></tr>\n <tr><td>{{refName}}</td><td colspan=\"2\"><a\n href=\"{{pipelineUrl}}\"\n >{{pipelineId}}</a></td></tr>\n</table>\n";
|
|
4
|
+
readonly 'build-package-version-notification': "<table>\n <tr><th colspan=\"3\" style=\"color: white; background-color: darkgreen;\">{{projectTitle}}: Package Version\n Created</th></tr>\n <tr><td>Version</td><td>Branch</td><td>Pipeline</td></tr>\n <tr><td>{{packageVersion}}<br />{{subscriberPackageVersionId}}</td><td>{{refName}}</td><td><a\n href=\"{{pipelineUrl}}\"\n >{{pipelineId}}</a></td></tr>\n <tr><td colspan=\"3\">Stories since {{packageVersionPrevious}}</td></tr>\n <tr><td colspan=\"3\">{{{storiesLinked}}}</td></tr>\n</table>\n";
|
|
3
5
|
readonly 'happy-soup-failure-notification': "<table>\n <tr><th colspan=\"3\" style=\"color: white; background-color: darkred;\">Failed Stage:\n {{stage}}</th></tr>\n <tr><td>Environment</td><td>Branch</td><td>Pipeline</td></tr>\n <tr><td>{{environmentName}}</td><td>{{refName}}</td><td><a\n href=\"{{pipelineUrl}}\"\n >{{pipelineId}}</a></td></tr>\n</table>\n";
|
|
4
6
|
readonly 'happy-soup-final-failure-notification': "<table>\n <tr><th colspan=\"3\" style=\"color: white; background-color: darkred;\">Happy Soup Deployment Failed</th></tr>\n <tr><td>Environment</td><td>Branch</td><td>Pipeline</td></tr>\n <tr><td>{{environmentName}}</td><td>{{refName}}</td><td><a\n href=\"{{pipelineUrl}}\"\n >{{pipelineId}}</a></td></tr>\n</table>\n";
|
|
5
7
|
readonly 'happy-soup-final-success-notification': "<table>\n <tr><th colspan=\"3\" style=\"color: white; background-color: darkgreen;\">Happy Soup Deployment\n Completed</th></tr>\n <tr><td>Environment</td><td>Branch</td><td>Pipeline</td></tr>\n <tr><td>{{environmentName}}</td><td>{{refName}}</td><td><a\n href=\"{{pipelineUrl}}\"\n >{{pipelineId}}</a></td></tr>\n{{#if upgradedPackages.length}}\n <tr><td colspan=\"3\">Upgraded Packages</td></tr>\n{{#each upgradedPackages}}\n <tr><td colspan=\"1\">{{packageName}}</td><td colspan=\"2\">{{{storiesLinked}}}</td></tr>\n{{/each}}\n{{/if}}\n</table>\n";
|
|
@@ -15,6 +15,27 @@
|
|
|
15
15
|
*/
|
|
16
16
|
/** Teams notification card templates, keyed the same as the original `.hbs` file names. */
|
|
17
17
|
export const NOTIFY_TEMPLATES = {
|
|
18
|
+
'build-failure-notification': `<table>
|
|
19
|
+
<tr><th colspan="3" style="color: white; background-color: darkred;">{{projectTitle}}: Failed Build</th></tr>
|
|
20
|
+
<tr><th colspan="3" style="color: white; background-color: grey;">Job: {{jobName}} (Stage:
|
|
21
|
+
{{stage}})</th></tr>
|
|
22
|
+
<tr><td>Branch</td><td colspan="2">Pipeline</td></tr>
|
|
23
|
+
<tr><td>{{refName}}</td><td colspan="2"><a
|
|
24
|
+
href="{{pipelineUrl}}"
|
|
25
|
+
>{{pipelineId}}</a></td></tr>
|
|
26
|
+
</table>
|
|
27
|
+
`,
|
|
28
|
+
'build-package-version-notification': `<table>
|
|
29
|
+
<tr><th colspan="3" style="color: white; background-color: darkgreen;">{{projectTitle}}: Package Version
|
|
30
|
+
Created</th></tr>
|
|
31
|
+
<tr><td>Version</td><td>Branch</td><td>Pipeline</td></tr>
|
|
32
|
+
<tr><td>{{packageVersion}}<br />{{subscriberPackageVersionId}}</td><td>{{refName}}</td><td><a
|
|
33
|
+
href="{{pipelineUrl}}"
|
|
34
|
+
>{{pipelineId}}</a></td></tr>
|
|
35
|
+
<tr><td colspan="3">Stories since {{packageVersionPrevious}}</td></tr>
|
|
36
|
+
<tr><td colspan="3">{{{storiesLinked}}}</td></tr>
|
|
37
|
+
</table>
|
|
38
|
+
`,
|
|
18
39
|
'happy-soup-failure-notification': `<table>
|
|
19
40
|
<tr><th colspan="3" style="color: white; background-color: darkred;">Failed Stage:
|
|
20
41
|
{{stage}}</th></tr>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/common/notify/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,2FAA2F;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,iCAAiC,EAAE;;;;;;;;CAQpC;IACC,uCAAuC,EAAE;;;;;;;CAO1C;IACC,uCAAuC,EAAE;;;;;;;;;;;;;;CAc1C;IACC,wCAAwC,EAAE;;;;;;;;CAQ3C;IACC,iCAAiC,EAAE;;;;;;;;;;;;;;CAcpC;IACC,8BAA8B,EAAE;;;;;;;;;;CAUjC;IACC,8BAA8B,EAAE;;;;;;;;;;CAUjC;CACS,CAAC"}
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/common/notify/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,2FAA2F;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,4BAA4B,EAAE;;;;;;;;;CAS/B;IACC,oCAAoC,EAAE;;;;;;;;;;CAUvC;IACC,iCAAiC,EAAE;;;;;;;;CAQpC;IACC,uCAAuC,EAAE;;;;;;;CAO1C;IACC,uCAAuC,EAAE;;;;;;;;;;;;;;CAc1C;IACC,wCAAwC,EAAE;;;;;;;;CAQ3C;IACC,iCAAiC,EAAE;;;;;;;;;;;;;;CAcpC;IACC,8BAA8B,EAAE;;;;;;;;;;CAUjC;IACC,8BAA8B,EAAE;;;;;;;;;;CAUjC;CACS,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Send a build job's failure, or the package version it created, to Microsoft Teams, with issue-tracker integration.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Run in every build job's `after_script`. Which card it posts depends on `--ci-job-status`:
|
|
8
|
+
|
|
9
|
+
- `failed`: a failure card with the job, stage, branch, and pipeline, whichever build job failed.
|
|
10
|
+
- `success`: a package version card, but only when the job created a package version. The card shows the new version tag, its `04t` ID, and the issue references in the commits since the previous version tag. Every other successful job sends nothing.
|
|
11
|
+
- Anything else (e.g. `canceled`): nothing.
|
|
12
|
+
|
|
13
|
+
The `04t` ID comes from `--subscriber-package-version-id`, or else from the `subscriberPackageVersionId.env` file that `build create-package-version` writes to the working directory. The new version's tag is the tag at `HEAD` annotated with that ID. The previous version's tag is the nearest earlier tag in the project's version tag format (`plugins.simply.versionTagFormat` or `SIMPLY_CICD_VERSION_TAG_FORMAT`). The command fetches tags, and the full history when the clone is shallow. If a tag or the history can't be found, the card shows `N/A` instead of failing the job.
|
|
14
|
+
|
|
15
|
+
# flags.ci-commit-ref-name.summary
|
|
16
|
+
|
|
17
|
+
The git branch or tag ref for this pipeline run.
|
|
18
|
+
|
|
19
|
+
# flags.ci-job-name.summary
|
|
20
|
+
|
|
21
|
+
The name of the current CI job.
|
|
22
|
+
|
|
23
|
+
# flags.ci-job-stage.summary
|
|
24
|
+
|
|
25
|
+
The stage of the current CI job.
|
|
26
|
+
|
|
27
|
+
# flags.ci-job-status.summary
|
|
28
|
+
|
|
29
|
+
The status of the current CI job (e.g. success, failed, canceled).
|
|
30
|
+
|
|
31
|
+
# flags.ci-pipeline-id.summary
|
|
32
|
+
|
|
33
|
+
The ID of the current CI pipeline.
|
|
34
|
+
|
|
35
|
+
# flags.ci-pipeline-url.summary
|
|
36
|
+
|
|
37
|
+
The URL of the current CI pipeline.
|
|
38
|
+
|
|
39
|
+
# flags.ci-project-title.summary
|
|
40
|
+
|
|
41
|
+
The project title shown in the notification card's heading.
|
|
42
|
+
|
|
43
|
+
# flags.subscriber-package-version-id.summary
|
|
44
|
+
|
|
45
|
+
The subscriber package version ID (04t...) created by this job. Defaults to the one in subscriberPackageVersionId.env, written by build create-package-version.
|
|
46
|
+
|
|
47
|
+
# flags.enabled.summary
|
|
48
|
+
|
|
49
|
+
Whether the notification is actually sent. Defaults to false so pipelines can gate this behind their own condition.
|
|
50
|
+
|
|
51
|
+
# flags.alm-base-url.summary
|
|
52
|
+
|
|
53
|
+
Base URL that an issue reference is appended to, e.g. https://jira.example.com/browse for Jira or https://gitlab.com/group/project/-/issues for GitLab Issues. References are shown without links if not provided.
|
|
54
|
+
|
|
55
|
+
# flags.alm-project-key.summary
|
|
56
|
+
|
|
57
|
+
Fallback project key(s) used to search commit messages for issue references, if none are configured in .sfdevrc.json. Only used by prefix-keyed trackers such as Jira.
|
|
58
|
+
|
|
59
|
+
# flags.alm-provider.summary
|
|
60
|
+
|
|
61
|
+
The issue tracker whose reference format to look for in commit messages.
|
|
62
|
+
|
|
63
|
+
# flags.teams-webhook-url.summary
|
|
64
|
+
|
|
65
|
+
One or more Teams webhook URLs to send the notification to.
|
|
66
|
+
|
|
67
|
+
# flags.debug.summary
|
|
68
|
+
|
|
69
|
+
Enable verbose debug logging.
|
|
70
|
+
|
|
71
|
+
# examples
|
|
72
|
+
|
|
73
|
+
- Post a card from a build job's after_script; it only sends one when the job failed or created a package version:
|
|
74
|
+
|
|
75
|
+
<%= config.bin %> <%= command.id %> --ci-job-name push-scratch --ci-job-status "$CI_JOB_STATUS" --teams-webhook-url https://outlook.office.com/webhook/... --enabled
|
|
76
|
+
|
|
77
|
+
- Announce a package version with linked Jira stories:
|
|
78
|
+
|
|
79
|
+
<%= config.bin %> <%= command.id %> --ci-job-status success --alm-base-url https://jira.example.com/browse --teams-webhook-url https://outlook.office.com/webhook/... --enabled
|
|
80
|
+
|
|
81
|
+
# error.missingTeamsWebhookUrl
|
|
82
|
+
|
|
83
|
+
--teams-webhook-url must be specified.
|
|
@@ -4,7 +4,7 @@ Send a serialized JSON payload to a Microsoft Teams webhook.
|
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
Posts a payload as-is to one or more Microsoft Teams incoming webhook URLs. Use this for custom notifications that don't fit the built-in `notify project
|
|
7
|
+
Posts a payload as-is to one or more Microsoft Teams incoming webhook URLs. Use this for custom notifications that don't fit the built-in `notify project`, `notify happy-soup`, or `notify build` card templates.
|
|
8
8
|
|
|
9
9
|
# flags.payload.summary
|
|
10
10
|
|