Skip to content

Commit e693795

Browse files
authored
fix: update monitoring configuration and enhance documentation for Azure integration (#1672)
* fix: update monitoring configuration and enhance documentation for Azure integration * doc
1 parent 5102a40 commit e693795

File tree

6 files changed

+212
-17
lines changed

6 files changed

+212
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
Note: Can be used with `sfdx plugins:install sfdx-hardis@beta` and docker image `hardisgroupcom/sfdx-hardis@beta`
66

7+
- [hardis:org:configure:monitoring](https://sfdx-hardis.cloudity.com/hardis/org/configure/monitoring/) enhancements:
8+
- Before deploying External Client App, check that there is not an already existing one with the same name
9+
- Suggest to git add+commit+push as soon as the branch is created to simplify configuration on Azure Pipelines
10+
- Improve assistance messages and links to documentation
711
- Enhance CI/CD documentation and error messages for Azure, GitHub, and Jenkins variable referencing
812

913
## [6.23.1] 2025-01-19

config/sfdx-hardis.jsonschema.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,8 @@
11431143
"SubscriberPackageVersionNumber": "2.11.0.1",
11441144
"installOnScratchOrgs": false,
11451145
"installDuringDeployments": true,
1146-
"installationkey": "MyInstallationKey"
1146+
"installationkey": "MyInstallationKey",
1147+
"VersionSettings": "namespace"
11471148
},
11481149
{
11491150
"Id": "0A35r000000GveVCAS",
@@ -1154,7 +1155,8 @@
11541155
"SubscriberPackageVersionName": "Summer2021",
11551156
"SubscriberPackageVersionNumber": "1.22.0.2",
11561157
"installOnScratchOrgs": true,
1157-
"installDuringDeployments": true
1158+
"installDuringDeployments": true,
1159+
"VersionSettings": "namespace"
11581160
}
11591161
]
11601162
],
@@ -1223,6 +1225,15 @@
12231225
"title": "Subscriber Version Number",
12241226
"type": "string"
12251227
},
1228+
"VersionSettings": {
1229+
"$Id": "#/properties/install/properties/packages/items/VersionSettings",
1230+
"examples": [
1231+
"namespace",
1232+
"none"
1233+
],
1234+
"title": "Version Settings",
1235+
"type": "string"
1236+
},
12261237
"installDuringDeployments": {
12271238
"$Id": "#/properties/install/properties/packages/items/installDuringDeployments",
12281239
"default": false,

docs/salesforce-monitoring-config-azure.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ description: Learn how to configure a monitoring repository for a Salesforce Org
55
<!-- markdownlint-disable MD013 -->
66

77
- [Pre-requisites](#pre-requisites)
8-
- [Create access token](#create-access-token)
9-
- [Create CI/CD variable](#create-cicd-variable)
8+
- [Configure a ByPass in Azure Settings](#configure-a-bypass-in-azure-settings)
109
- [Run sfdx-hardis configuration command](#run-sfdx-hardis-configuration-command)
1110
- [Define sfdx-hardis environment variables](#define-sfdx-hardis-environment-variables)
1211
- [Schedule the monitoring job](#schedule-the-monitoring-job)

docs/schema/sfdx-hardis-json-schema-parameters.html

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5123,6 +5123,59 @@ <h2 class="mb-0">
51235123
</div>
51245124
</div>
51255125
</div>
5126+
<div class="accordion" id="accordioninstalledPackages_items_VersionSettings">
5127+
<div class="card">
5128+
<div class="card-header" id="headinginstalledPackages_items_VersionSettings">
5129+
<h2 class="mb-0">
5130+
<button class="btn btn-link property-name-button" type="button" data-toggle="collapse" data-target="#installedPackages_items_VersionSettings"
5131+
aria-expanded="" aria-controls="installedPackages_items_VersionSettings" onclick="setAnchor('#installedPackages_items_VersionSettings')"><span class="property-name">VersionSettings</span></button>
5132+
</h2>
5133+
</div>
5134+
5135+
<div id="installedPackages_items_VersionSettings"
5136+
class="collapse property-definition-div" aria-labelledby="headinginstalledPackages_items_VersionSettings"
5137+
data-parent="#accordioninstalledPackages_items_VersionSettings">
5138+
<div class="card-body pl-5">
5139+
5140+
<div class="breadcrumbs">root
5141+
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrow-right-short" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
5142+
<path
5143+
fill-rule="evenodd"
5144+
d="M4 8a.5.5 0 0 1 .5-.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5A.5.5 0 0 1 4 8z"
5145+
/>
5146+
</svg>
5147+
<a href="#installedPackages" onclick="anchorLink('installedPackages')">installedPackages</a>
5148+
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrow-right-short" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
5149+
<path
5150+
fill-rule="evenodd"
5151+
d="M4 8a.5.5 0 0 1 .5-.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5A.5.5 0 0 1 4 8z"
5152+
/>
5153+
</svg>
5154+
<a href="#installedPackages_items" onclick="anchorLink('installedPackages_items')">Salesforce package</a>
5155+
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrow-right-short" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
5156+
<path
5157+
fill-rule="evenodd"
5158+
d="M4 8a.5.5 0 0 1 .5-.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5A.5.5 0 0 1 4 8z"
5159+
/>
5160+
</svg>
5161+
<a href="#installedPackages_items_VersionSettings" onclick="anchorLink('installedPackages_items_VersionSettings')">VersionSettings</a></div><h4>Version Settings</h4><span class="badge badge-dark value-type">Type: string</span><br/>
5162+
5163+
5164+
5165+
5166+
5167+
5168+
<br/>
5169+
<div class="badge badge-secondary">Examples:</div>
5170+
<br/><div id="installedPackages_items_VersionSettings_ex1" class="jumbotron examples"><div class="highlight"><pre><span></span><span class="s2">&quot;namespace&quot;</span>
5171+
</pre></div>
5172+
</div><div id="installedPackages_items_VersionSettings_ex2" class="jumbotron examples"><div class="highlight"><pre><span></span><span class="s2">&quot;none&quot;</span>
5173+
</pre></div>
5174+
</div>
5175+
</div>
5176+
</div>
5177+
</div>
5178+
</div>
51265179
<div class="accordion" id="accordioninstalledPackages_items_installDuringDeployments">
51275180
<div class="card">
51285181
<div class="card-header" id="headinginstalledPackages_items_installDuringDeployments">
@@ -5299,7 +5352,8 @@ <h2 class="mb-0">
52995352
<span class="w"> </span><span class="s2">&quot;SubscriberPackageVersionNumber&quot;</span><span class="o">:</span><span class="w"> </span><span class="s2">&quot;2.11.0.1&quot;</span><span class="p">,</span>
53005353
<span class="w"> </span><span class="s2">&quot;installOnScratchOrgs&quot;</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span>
53015354
<span class="w"> </span><span class="s2">&quot;installDuringDeployments&quot;</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span>
5302-
<span class="w"> </span><span class="s2">&quot;installationkey&quot;</span><span class="o">:</span><span class="w"> </span><span class="s2">&quot;MyInstallationKey&quot;</span>
5355+
<span class="w"> </span><span class="s2">&quot;installationkey&quot;</span><span class="o">:</span><span class="w"> </span><span class="s2">&quot;MyInstallationKey&quot;</span><span class="p">,</span>
5356+
<span class="w"> </span><span class="s2">&quot;VersionSettings&quot;</span><span class="o">:</span><span class="w"> </span><span class="s2">&quot;namespace&quot;</span>
53035357
<span class="w"> </span><span class="p">},</span>
53045358
<span class="w"> </span><span class="p">{</span>
53055359
<span class="w"> </span><span class="s2">&quot;Id&quot;</span><span class="o">:</span><span class="w"> </span><span class="s2">&quot;0A35r000000GveVCAS&quot;</span><span class="p">,</span>
@@ -5310,7 +5364,8 @@ <h2 class="mb-0">
53105364
<span class="w"> </span><span class="s2">&quot;SubscriberPackageVersionName&quot;</span><span class="o">:</span><span class="w"> </span><span class="s2">&quot;Summer2021&quot;</span><span class="p">,</span>
53115365
<span class="w"> </span><span class="s2">&quot;SubscriberPackageVersionNumber&quot;</span><span class="o">:</span><span class="w"> </span><span class="s2">&quot;1.22.0.2&quot;</span><span class="p">,</span>
53125366
<span class="w"> </span><span class="s2">&quot;installOnScratchOrgs&quot;</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span>
5313-
<span class="w"> </span><span class="s2">&quot;installDuringDeployments&quot;</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span>
5367+
<span class="w"> </span><span class="s2">&quot;installDuringDeployments&quot;</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span>
5368+
<span class="w"> </span><span class="s2">&quot;VersionSettings&quot;</span><span class="o">:</span><span class="w"> </span><span class="s2">&quot;namespace&quot;</span>
53145369
<span class="w"> </span><span class="p">}</span>
53155370
<span class="p">]</span>
53165371
</pre></div>

src/commands/hardis/org/configure/monitoring.ts

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
generateSSLCertificate,
1414
getCurrentGitBranch,
1515
getGitRepoName,
16+
git,
1617
gitAddCommitPush,
1718
uxLog,
1819
} from '../../../../common/utils/index.js';
@@ -116,12 +117,14 @@ The command's technical implementation involves a series of Git operations, file
116117
}
117118
const preRequisitesUrl = `${CONSTANTS.DOC_URL_ROOT}/salesforce-monitoring-config-home/#instructions`;
118119
uxLog("warning", this, c.yellow('Monitoring pre-requisites documentation: ' + c.bold(preRequisitesUrl)));
120+
WebSocketClient.sendReportFileMessage(preRequisitesUrl, 'Monitoring pre-requisites', "docUrl");
121+
// Confirm pre-requisites
119122
const confirmPreRequisites = await prompts({
120123
type: 'select',
121124
name: 'value',
122125
choices: [
123-
{ title: 'Yes', value: 'yes' },
124-
{ title: 'No, help me !', value: 'no' },
126+
{ title: '😎 Yes', value: 'yes' },
127+
{ title: 'ℹ️ No, bring me to the documentation!', value: 'no' },
125128
],
126129
message: c.cyanBright('Did you configure the sfdx-hardis monitoring pre-requisites on your Git server ?'),
127130
description: 'Confirm that you have set up the required CI/CD variables and permissions for monitoring',
@@ -179,10 +182,12 @@ The command's technical implementation involves a series of Git operations, file
179182
.replace(/--/gm, '__')
180183
.replace(/-/gm, '_');
181184

185+
uxLog("action", this, c.cyan(`Handling monitoring git branch ${c.bold(branchName)}...`));
186+
182187
// Checkout branch, or create it if not existing (stash before if necessary)
183188
await execCommand('git add --all', this, { output: true, fail: false });
184189
await execCommand('git stash', this, { output: true, fail: false });
185-
await ensureGitBranch(branchName, { parent: 'main' });
190+
await ensureGitBranch(branchName, { parent: 'main', logAsAction: true });
186191

187192
// Create sfdx project if not existing yet
188193
if (!fs.existsSync('sfdx-project.json')) {
@@ -215,6 +220,26 @@ The command's technical implementation involves a series of Git operations, file
215220
'./.sfdx-hardis.yml'
216221
);
217222

223+
// Check if current branch is existing on remote origin, and if not suggest to push (with confirmation)
224+
const remoteBranches = await git().listRemote(['--heads', 'origin']);
225+
const branchExistsOnRemote = remoteBranches.includes(`refs/heads/${branchName}`);
226+
if (!branchExistsOnRemote) {
227+
const confirmPushToRemote = await prompts({
228+
type: 'confirm',
229+
initial: true,
230+
message: c.cyanBright(
231+
`Branch ${branchName} does not exist on server. Do you want to push it now? (it is harmless but required to configure Azure Pipelines for example)`
232+
),
233+
description: 'This will create the branch on remote origin; if you don\'t understand this, just say yes 😊',
234+
});
235+
if (confirmPushToRemote.value === true) {
236+
uxLog("action", this, c.cyan(`Pushing branch ${c.bold(branchName)} to git remote server...`));
237+
await gitAddCommitPush({
238+
message: '[sfdx-hardis] Update monitoring configuration',
239+
});
240+
}
241+
}
242+
218243
// Generate SSL certificate (requires openssl to be installed on computer)
219244
await generateSSLCertificate(branchName, './.ssh', this, flags['target-org'].getConnection(), {});
220245

@@ -239,9 +264,9 @@ The command's technical implementation involves a series of Git operations, file
239264
}
240265
const branch = await getCurrentGitBranch();
241266
uxLog(
242-
"success",
267+
"warning",
243268
this,
244-
c.green(
269+
c.yellow(
245270
`Now you must schedule monitoring to run the job automatically every night on branch ${c.bold(branch)}😊`
246271
)
247272
);
@@ -250,7 +275,23 @@ The command's technical implementation involves a series of Git operations, file
250275
'Please follow the instructions to schedule sfdx-hardis monitoring on your Git server: ' +
251276
c.bold(scheduleMonitoringUrl);
252277
uxLog("warning", this, c.yellow(msg));
253-
await open(scheduleMonitoringUrl, { wait: true });
278+
WebSocketClient.sendReportFileMessage(scheduleMonitoringUrl, 'Schedule sfdx-hardis monitoring', "actionUrl");
279+
uxLog(
280+
"warning",
281+
this,
282+
c.yellow(
283+
'You can also configure Slack/Teams notifications and Grafana integration to visualize monitoring results more easily.'
284+
)
285+
);
286+
const slackIntegrationUrl = `${CONSTANTS.DOC_URL_ROOT}/salesforce-ci-cd-setup-integration-slack/`;
287+
WebSocketClient.sendReportFileMessage(slackIntegrationUrl, 'Slack integration', "docUrl");
288+
const teamsIntegrationUrl = `${CONSTANTS.DOC_URL_ROOT}/salesforce-ci-cd-setup-integration-ms-teams/`;
289+
WebSocketClient.sendReportFileMessage(teamsIntegrationUrl, 'Teams integration', "docUrl");
290+
const grafanaIntegrationUrl = `${CONSTANTS.DOC_URL_ROOT}/salesforce-ci-cd-setup-integration-api/`;
291+
WebSocketClient.sendReportFileMessage(grafanaIntegrationUrl, 'Grafana integration', "docUrl");
292+
uxLog("log", this, 'Slack integration doc: ' + slackIntegrationUrl);
293+
uxLog("log", this, 'Teams integration doc: ' + teamsIntegrationUrl);
294+
uxLog("log", this, 'Grafana integration doc: ' + grafanaIntegrationUrl);
254295
// Return an object to be displayed with --json
255296
return { outputString: 'Configured branch for authentication' };
256297
}

0 commit comments

Comments
 (0)