v7.4.0 - Validation rules
Features
- #1643 validation rules for retrieve, buildDefinition and deploy by @JoernBerkefeld in #1648
- #1645 option to define custom validation rules for retrieve, buildDefinition and deploy by @JoernBerkefeld in #1649
- #1666 optional validation rule overrides per types via .mcdevrc config by @JoernBerkefeld in #1667
- #1671 add option to reduce validation rule errors to warnings via option
--skipValidation
for deploy, build, buildDefinition, buildDefinitionBulk by @JoernBerkefeld in #1672 - #1434 add
resume journey
viaexecute
-method (including adding an aliasresume
for that command) by @JoernBerkefeld in #1630 - #1651: allow using
--matchName
withdeploy dataExtension
(this previously only worked withasset
) by @JoernBerkefeld in #1656
Bugfixes
- #1505 fix incorrect asset links in
journeys
when retrieved together withtriggeredSends
by @JoernBerkefeld in #1640 - #1472 fix dependency-not-found deploy-error by adapting order in which
assets
are deployed, solving the inter-type dependencies by @JoernBerkefeld in #1502 - #1646 fix config files not actually getting updated during mcdev upgrade when it was presented as optional by @JoernBerkefeld in #1647
- #1644 automatic workaround, not solution for the "string or binary data would be truncated"-error by @JoernBerkefeld in #1660
- #1657 fix
journey
/event
eventDataSummary not getting saved correctly by @JoernBerkefeld in #1658 - #1668 sf object checks for
events
andjourneys
fail if multiple entries are retrieved-by-key due to race conditions by @JoernBerkefeld in #1669
Chores
- #1637 enable syntax highlighting for SSJS files in GitLab by @JoernBerkefeld in #1638
Full Changelog: v7.3.1...v7.4.0
Details
Standard Commands
deploy
Command: mcdev deploy [business unit] [metadata type] [metadata key] [--metadata] [--fromRetrieve] [--refresh] [--keySuffix] [--noMidSuffix] [--changeKeyValue=yourNewKey] [--changeKeyField=otherFieldInJson] [--execute] [--schedule] [--fixShared] [--noUpdate] [--publish] [--skipStatusCheck] [--matchName] [--skipValidation]
New option --skipValidation
deploy with --matchName:
Currently supported types:
Name | CLI Argument |
---|---|
Asset | asset |
Data Extension | dataExtension |
deploy --matchName
now supports dataExtensions
execute
Command: mcdev execute <business unit> [type] [key] [--like] [--schedule] [--metadata]
Alias: mcdev exec
/ mcdev start
/ mcdev resume
Currently supported types:
Name | CLI Argument | Effect |
---|---|---|
Automation | automation |
RunOnce or Schedules automation according to already existing schedule |
Query | query |
Starts query execution |
Journey | journey |
Resumes a paused journey |
Now supports
journey
publish
Command: mcdev publish <business unit> [metadata type] [metadata key] [--like] [--skipStatusCheck] [--metadata]
Alias: mcdev activate
Currently supported types:
Name | CLI Argument | Effect |
---|---|---|
Journey | journey |
Activates a Draft-version of a journey (creates related transactionalEmail or event record) |
New alias
activate
to mimic the lingo in Journey Builder
Templating Commands
build
Command: mcdev build <--buFrom> <--marketFrom> <--buTo> <--marketTo> <--metadata> [--bulk] [--dependencies] [--retrieve] [--skipValidation]
New option --skipValidation
buildDefinition
Command: mcdev buildDefinition <business unit> [type] [template name] [market] [--metadata] [--market] [--skipValidation]
New option --skipValidation
buildDefinitionBulk
Command: mcdev buildDefinitionBulk <market list name> <type> <template name> [--metadata] [--skipValidation]
New option --skipValidation
Advanced Configuration
.mcdevrc.json
The central config in .mcdevrc.json
holds multiple adjustable settings:
{
"options": {
"validation": {
"retrieve": {
"noGuidKeys": "warn",
"noRootFolder": "warn",
"overrides": [
{
"type": [
"journey"
],
"options": {
"noGuidKeys": "off",
}
}
]
},
"buildDefinition": {
"noGuidKeys": "warn",
"noRootFolder": "warn",
"overrides": [
{
"type": [
"journey"
],
"options": {
"noGuidKeys": "off",
}
}
]
},
"deploy": {
"noGuidKeys": "error",
"noRootFolder": "error",
"overrides": [
{
"type": [
"journey"
],
"options": {
"noGuidKeys": "off",
}
}
]
}
},
},
}
Setting | Default | Description |
---|---|---|
options.validation | current default and custom rules | Allows setting validation rules to "off", "warn" or "error |
Validation rules
You can define validation rules for retrieve
, buildDefinition
and deploy
.
The following rules exist out of the box:
- noGuidKeys: test for metadata that has a GUID / UUID as key.
- noRootFolder: test if metadata that does exist in a folder resides in the root for that particular type or in a subfolder.
Possible rule settings are:
- not set, which implicitly turns off the rule
- "off" explicitly turns off the rule
- "warn" shows a log message of type warning
- "error" shows a log message of type error AND blocks further execution
- for
retrieve
that prevents download - for
buildDefintion
(andbuild
) that prevents the creation of the corresponding file in the deploy folder - for
deploy
this will prevent deployment.
- for
Please keep in mind that you can always skip validation rules all together at run-time by adding --skipValidation to your command (deploy / build / buildDefinition / buildDefinitionBulk)
Custom Validation rules - .mcdev-validation.js
Optionally one can create a file named .mcdev-validations.js
in the root of your project to specify your own validation rules. That gives you full flexibility to test for whatever guidelines you might have as you can literally parse the JSON of the metadata yourself.
One example that depends on BU names and hence is not part of the standard set could look like this:
'use strict';
const buSuffixMap = {
_ParentBU_: '',
DEV: '_DEV',
QA: '_QA',
PROD: '',
};
/**
*
* @param {any} definition type defintiion
* @param {any} item metadata json
* @param {string} targetDir where the metadata is stored ("deploy/cred/bu")
* @param {any} Util helper methods
* @returns {Promise.<any>} validation rule
*/
export function validation(definition, item, targetDir, Util) {
const bu = targetDir.includes('/') ? targetDir.split('/').pop() : targetDir.split('\\').pop();
const suffix = buSuffixMap[bu];
if (suffix === undefined) {
Util.logger.error(
`BU '${bu}' not defined for keySuffix validation in .mcdev-validations.js`
);
}
return {
keySuffix: {
failedMsg: 'Key Suffix expected but not found: ' + suffix,
/**
* @returns {boolean} true=test passed
*/
passed: function () {
// exclude non-relevant items
const relevantTypes = ['asset', 'dataExtension'];
if (!relevantTypes.includes(definition.type)) {
return true;
}
if (
definition.type === 'dataExtension' &&
item.r__folder_ContentType !== 'shared_dataextension'
) {
// only shared DEs need a suffix
return true;
}
// actual test
const key = item[definition.keyField] + '';
if (key) {
return key.endsWith(suffix);
} else {
Util.logger.debug('validation-keySuffix: key not found');
return true;
}
},
},
};
}
To control how a custom rule is applied, simply add its name (in the above example, keySuffix
) to options.validation like you would for the default rules. Because custom rules are configured in the same way as default rules, you can also use the same override logic for them
"validation": {
"retrieve": {
"keySuffix": "warn",
"noGuidKeys": "warn",
"noRootFolder": "warn",
},
"buildDefinition": {
"keySuffix": "warn",
"noGuidKeys": "warn",
"noRootFolder": "warn",
"overrides": [
{
"type": [
"asset"
],
"options": {
"keySuffix": "error",
}
}
]
},
"deploy": {
"keySuffix": "error",
"noGuidKeys": "error",
"noRootFolder": "error",
}
},