SalesforceCommerceCloud / sfcc-ci

Salesforce Commerce Cloud CLI

Home Page:https://npmjs.com/package/sfcc-ci

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HELP Needed:SFCC-CI code:deploy fails when adding the archive file to the command line

irobotbfealy opened this issue · comments

I'm trying to run sfcc-ci to do a code:deploy. I've tried running the command line in various formats, but have found that whenever I add an archive file name -- no matter how it's decorated (full path, file name only, with and without quotes in both cases, etc) the command line is failing whenever an archive is present with a type mismatch.

Any suggestions would be appreciated, the logs below are from a command window, I've seen the same from our Bamboo build, and in cases both WITH and WITHOUT the environment variables for username, client ID, client secret, etc. defined -- nothing seems to make it work, and the error's always the same type mismatch.

Example outputs from a few different runs:

Testing running with just the help flag:
C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1>"C:\Program Files\nodejs\node.exe" "C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1\node_modules\sfcc-ci\cli.js" code:deploy --help
Usage: code:deploy [options]

Deploys a custom code archive onto a Commerce Cloud instance

Options:
-i, --instance Instance to deploy the custom code archive to. Can be an instance alias. If not specified the currently configured instance will be used.
-a, --activate Whether to activate the deployed code version, false by default
-c, --certificate Path to the certificate to use for two factor authentication.
-p, --passphrase Passphrase to be used to read the given certificate.
-h, --help output usage information

Details:

The deployed archive file will be unpacked on the instance. It is recommended to use
a top level folder as the code version containing the cartridges:

code_version.zip
|-- code_version
|-- cartridge1
|-- cartridge2
|-- cartridge3

Use the optional --activate flag to activate the deployed code version. This assumes
that the deployed archive file has the same name as the enclosed code version.

If you deploy to staging and make use of a certificate file the instance host name
(e.g. cert.staging.realm.org.demandware.net) will be modified for the subsequent activation
(e.g. staging.realm.org.demandware.net).

Examples:

$ sfcc-ci code:deploy code_version.zip
$ sfcc-ci code:deploy code_version.zip -i my-instance-alias
$ sfcc-ci code:deploy code_version.zip -i my-instance.demandware.net
$ sfcc-ci code:deploy code_version.zip -i my-instance.demandware.net -c path/to/my/certificate.p12 -p "myPassphraseForTheCertificate"
$ sfcc-ci code:deploy code_version.zip --activate

Testing with Instance:

Without ZIP parameter:
C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1>"C:\Program Files\nodejs\node.exe" "C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1\node_modules\sfcc-ci\cli.js" code:deploy --instance instance.demandware.net
error: missing required argument `archive'

With ZIP parameter:
C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1>"C:\Program Files\nodejs\node.exe" "C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1\node_modules\sfcc-ci\cli.js" code:deploy --instance instance.demandware.net test.zip
C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1\node_modules\sfcc-ci\lib\code.js:135
throw new TypeError('Parameter token is missing or not of type String');
^

TypeError: Parameter token is missing or not of type String
at deployCode (C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1\node_modules\sfcc-ci\lib\code.js:135:15)
at Object.deploy (C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1\node_modules\sfcc-ci\lib\code.js:401:9)
at Command. (C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1\node_modules\sfcc-ci\cli.js:1174:35)
at Command.listener (C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1\node_modules\commander\index.js:315:8)
at Command.emit (events.js:223:5)
at Command.parseArgs (C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1\node_modules\commander\index.js:651:12)
at Command.parse (C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1\node_modules\commander\index.js:474:21)
at Object. (C:\Bamboo_Work\build-dir\50397185\SFRA-DEV-JOB1\node_modules\sfcc-ci\cli.js:2144:9)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)

I've redacted our instance name in the above examples, but do have it fully specified out in the demandware.net format for the specific system I'm using.

Hi @irobotbfealy

This would generally occur because you have not performed any authentication step yet. sfcc-ci does not implicitly authenticate when running a command like code:deploy. So you'll want to start with an sfcc-ci auth:login or a sfcc-ci client:auth. Since this appears to be a CI/CD situation and you mentioned you are setting client ID and secret environment variables you should be able to execute something like this:

$ sfcc-ci client:auth

Keep in mind that's if you're already setting the SFCC_OAUTH_CLIENT_ID and SFCC_OAUTH_CLIENT_SECRET environment variables. If not you can specify on the CLI: sfcc-ci client:auth [clientid] [client_secret]

After that the code:deploy command should get further along. If you are still getting the error even when authenticating during your run let us know.

Thanks, that resolved the first set of issues, much appreciate the help.