Skip to content

06.b ~ Standard Commands

Jörn Berkefeld edited this page May 4, 2023 · 28 revisions

retrieve

Command: mcdev retrieve [business unit] [metadata type] [metadata key]

Alias: mcdev r

Retrieves all metadata from the specified Business Unit. You can limit what types are retrieved by default using the selectTypes command or by changing the list in the config file directly.

Example:

mcdev retrieve MyProject/DEV

You can omit the Business Unit which will trigger an interactive mode based on your config:

Example:

mcdev retrieve

If you already know the credentials name but want to only select the Business Unit interactively try this Example:

mcdev retrieve MyProject

retrieve specific type:

If you want to retrieve only a certain metadata type, let's say script, then pass this type in as a second parameter. The other types will remain untouched and in place, if you've previously retrieved them.

Similarly, you can pass in multiple comma-separated types but make sure to put them in double quotes to work on all systems.

Example:

mcdev retrieve MyProject/DEV script
mcdev retrieve MyProject/DEV "script,query,automation"

retrieve specific type and key:

If you wish you may also specify the exact keys that need to be retrieved, filtering down on what's in your retrieve folder even further. Specified keys apply as a filter for all types you specify. If your naming convention does not allow for such an aggregation then please run separate commands for each type.

Example:

mcdev retrieve MyProject/DEV dataExtension "key1"
mcdev retrieve MyProject/DEV dataExtension "key1,key2"
mcdev retrieve MyProject/DEV "script,dataExtension,importFile" "key1,key2"

Note: This is not supported by types discovery and folder.

retrieve all BUs:

A special variant of this command allows you to retrieve all Business Units of a given credential at once. Example:

mcdev retrieve MyProject/*

or even

mcdev retrieve "*"

Note: retrieve-all will fail in some CLIs if you do not wrap the asterix (*) in quotes. This is due to the special meaning of * as a parameter in these CLIs.

deploy

Command: mcdev deploy [business unit] [metadata type] [metadata key] [--fromRetrieve] [--refresh] [--changeKeyValue=yourNewKey] [--changeKeyField=otherFieldInJson]

Alias: mcdev d

Deploys metadata to the specified Business Unit. Example:

mcdev deploy MyProject/DEV

Only metadata that you copied into the deploy directory will be deployed. Please keep in mind that the folder structure needs to be similar to what the retrieve command creates in the retrieve folder, including the credentials and Business Unit name.

Similarly to mcdev retrieve you can also use the interactive mode to select credential and/or Business Unit.

deploy sepcific type:

If you want to deploy only a certain metadata type, let's say dataExtension, then pass this type in as a second parameter. If there are other types in the current BU's deploy folder, these will be ignored and hence not uploaded.

Similarly, you can pass in multiple comma-separated types but make sure to put them in double quotes to work on all systems.

Example:

mcdev deploy MyProject/DEV dataExtension
mcdev deploy MyProject/DEV "script,dataExtension,importFile"

deploy specific type and key:

If you wish you may also specify the exact keys that need to be deployed, filtering down on what's in your deploy folder even further. Specified keys apply as a filter for all types you specify. If your naming convention does not allow for such an aggregation then please run separate commands for each type.

Example:

mcdev deploy MyProject/DEV dataExtension "key1"
mcdev deploy MyProject/DEV dataExtension "key1,key2"
mcdev deploy MyProject/DEV "script,dataExtension,importFile" "key1,key2"

deploy from retrieve folder:

Sometimes it's convenient to deploy right from the retrieve folder when you are using mcdev as a developer tool rather than only for deployments to other BUs. For this scenario we added the 4th parameter. In that case, it does not look into deploy/ but into retrieve/ finding what it needs to deploy. Example:

mcdev deploy MyProject/DEV dataExtension "key1" --fromRetrieve
mcdev deploy MyProject/DEV dataExtension "key1,key2" --fromRetrieve
mcdev deploy MyProject/DEV "script,dataExtension,importFile" "key1,key2" --fromRetrieve

deploy and change key:

Because of the special nature of the key field (with its various names across the metadata types) it cannot be simply updated by changing the value in the JSON. A deployment would otherwise trigger creating a new entry instead of updating the existing one. To still allow you to change the key value, like you could in the GUI, you have to use the optional parameters --changeKeyValue or --changeKeyField

Examples:

mcdev deploy MyProject/DEV dataExtension --changeKeyField=Name
mcdev deploy MyProject/DEV dataExtension key1 --changeKeyValue=key2

The first of the 2 commands using --changeKeyField will deploy all dataExtensions in the deploy folder and try to overwrite their key with their name. Please ensure you check how that other field is spelled including upper-/lower-cased letters.

The second command uses --changeKeyValue can only be used if type AND key are specified. You pass along the exact new key value that we want to end up with. Therefore, in this example, your dataExtension with key "key1" will be updated to have the key "key2".

Note: Not every type allows updating the key. Please check our Metadata Type Support page for a full list.

deploy and refresh:

This is a special combination that will only work if you UPDATE an asset that happens to be an e-mail that is used in a triggeredSend. In that case, after the asset(s) were updated it will automatically invoke the refresh command for any triggeredSend that uses one of the updated e-mails.

Examples:

mcdev deploy --refresh
mcdev deploy MyProject/DEV "asset,dataExtension" "key1,key2" --refresh
mcdev deploy MyProject/DEV asset "key1" --fromRetrieve --refresh

deploy all BUs:

A special variant of this command allows you to deploy all Business Units of a given credential at once. Example:

mcdev deploy MyProject/*

or even

mcdev deploy "*"

Note: deploy-all will fail in some CLIs if you do not wrap the asterix (*) in quotes. This is due to the special meaning of * as a parameter in these CLIs.

delete

Command: mcdev delete <business unit> <type> <external key>

Alias: mcdev del

Deletes the given metadata from your server. This needs to be run with care as any data stored in the deleted meta-data will be lost.

Currently supported types: Metadata Type Support

Example:

mcdev delete MyProject/_ParentBU_ dataExtension MyUserTable

mcdev delete MyProject/_ParentBU_ dataExtensionField MyUserTable.MyFieldName

mcdev del MyProject/_ParentBU_ interaction id:%235cfb1bcb-9cb7-42c9-81de-033943bbc18c/4

Note: For interaction (Journey) only, you can provide a key or an ID. In addition, you have to supply the version you want to delete by appending "/" and then the version. Also, when copying the ID from the URL, you might notice it's prefixed with "%23", which will automatically be filtered if you did copy it. In the above example, we are trying to delete version 4 of ID "5cfb1bcb-9cb7-42c9-81de-033943bbc18c".

refresh

Command: mcdev refresh <business unit> [type] [external key]

Alias: mcdev re

This commands lets you refresh the metadata of a given type and key. Currently this is only supported for Triggered Sends, therefore, if you do not specify a type, it will default to triggeredSendDefinition.

If you do not specify keys, for triggeredSendDefinition, it will refresh all running ("Active") triggered sends on the given BU. It will also check if all dependencies for that triggered send are available to ensure it can be published & restarted after it was paused. However, if you made changes to the email that cause issues, you might still get an error, which prevents you from restarting it. If you updated lots of emails and want your journeys (and triggered sends) to pick up the changes choose this version of the command.

Currently supported types:

Name CLI Argument Effect
Triggered Send triggeredSendDefinition Refreshes emails in active triggeredSends and thereby any emails in Journeys.

Example:

mcdev re MyProject/_ParentBU_

mcdev refresh MyProject/_ParentBU_ triggeredSendDefinition myKey

mcdev refresh MyProject/_ParentBU_ triggeredSendDefinition "myKey,myOtherKey"

mcdev refresh MyProject/_ParentBU_ . "myKey,myOtherKey"