SalesforceCommerceCloud / b2c-crm-sync

... a contemporary perspective on how to integrate B2C Commerce and the Salesforce Customer 360 Platform to power frictionless customer experiences in the B2C domain.
https://salesforcecommercecloud.github.io/b2c-crm-sync/
BSD 3-Clause "New" or "Revised" License
65 stars 45 forks source link

Error deploying to production org during metadata deployment #175

Closed orvischoinierec closed 1 year ago

orvischoinierec commented 2 years ago

Describe the bug

We're trying to deploy to our production org using the CLI. We've set up the .env settings appropriately and are able to make all necessary connections. However, we are stuck trying to deploy our metadata

We receive the following error when trying to execute the deploy command. We also have personaccounts enabled so this command deploys both base and personaccounts

Command

npm run crm-sync:sf:org:deploy

Output

[
  {
    "stack": "sf:INVALID_OPERATION: INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations\n    at module.exports.HttpApi.getError (/Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/jsforce/lib/http-api.js:250:13)\n    at /Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/jsforce/lib/http-api.js:95:22\n    at tryCallOne (/Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/promise/lib/core.js:37:12)\n    at /Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/promise/lib/core.js:123:15\n    at flush (/Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/asap/raw.js:50:29)\n    at processTicksAndRejections (node:internal/process/task_queues:75:11)\nOuter stack:\n    at Function.wrap (/Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/@salesforce/core/lib/sfdxError.js:171:27)\n    at SourceDeployCommand.catch (/Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/salesforce-alm/dist/ToolbeltCommand.js:253:46)\n    at async SourceDeployCommand._run (/Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/@salesforce/command/lib/sfdxCommand.js:85:13)",
    "message": "INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations",
    "name": "sf:INVALID_OPERATION",
    "exitCode": 1,
    "commandName": "SourceDeployCommand",
    "code": "Error"
  }
]

In order resolve this issue we added the following lines to lib/cli-api/_sfOrgDeploy.js

deployArguments.testLevel = 'RunSpecifiedTests';
deployArguments.runTests = 'B2CAuthTokenHelper';

After adding these lines we get the following error

[
  {
    "stack": "DeployFailed: Deploy failed.\n    at /Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/salesforce-alm/dist/lib/source/sourceApiCommand.js:71:31\n    at async SourceDeployCommand.execLegacyCommand (/Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/salesforce-alm/dist/ToolbeltCommand.js:149:29)\n    at async SourceDeployCommand.run (/Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/salesforce-alm/dist/commands/force/source/deploy.js:32:16)\n    at async SourceDeployCommand._run (/Users/choinierec/projects/b2ccrm-sync-orvis/node_modules/@salesforce/command/lib/sfdxCommand.js:81:40)",
    "message": "Deploy failed.",
    "name": "DeployFailed",
    "actions": [
      "Check the order of your dependencies and ensure all metadata is included."
    ],
    "exitCode": 1,
    "columns": [
      {
        "key": "problemType",
        "label": "TYPE"
      },
      {
        "key": "filePath",
        "label": "PROJECT PATH"
      },
      {
        "key": "error",
        "label": "PROBLEM"
      }
    ],
    "data": [
      {
        "error": "Unknown",
        "height": 1
      }
    ],
    "commandName": "SourceDeployCommand",
    "code": "Error"
  }
]

Expected behavior Metadata should deploy

Your local environment details:

Your remote environment details:

Additional context

There doesn't appear to be any solid instructions on how to deploy this project to a production org. If there is an established way to move metadata to a production org please document how this is done. We looked into change sets however there are so many files it did not seem feasible. Help with this error or guidance on how to move our metadata and this project to production would be greatly appreciated. We are all set on the commerce cloud side as we have deep experience there.

jbachelet commented 1 year ago

As already stated in the readme and the b2c-crm-sync documentation, the CLI commands provided in the repository ARE NOT HERE TO BE USED TO DEPLOY TO PRODUCTION.

Please create a proper CI/CD and release management process to deploy to your production org safely.

avarma4213 commented 1 year ago

@orvischoinierec Hi Sir, we are facing the same issue, all the components are deployed but the test are failing and thus it is rolling back our deployment to unscussefull in production.

Did you resolve the issue? if yes could you please guide me.

Thanks, AShok

rajjade38 commented 10 months ago

@avarma4213 Were you able to resolve the test class errors during deployment to production.