forcedotcom / cli

Salesforce CLI
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/
BSD 3-Clause "New" or "Revised" License
474 stars 77 forks source link

pipeline still failing #2922

Closed GMlynda closed 1 week ago

GMlynda commented 3 weeks ago

Note Before you submit your issue, make sure that:

  • You're using the latest version of Salesforce CLI.
  • You've searched both open and closed issues for related posts.
  • You've used the doctor command to diagnose common issues.
  • You understand that GitHub Issues don't adhere to any agreement or SLA.
    • If you require immediate assistance, use official channels such as Salesforce Customer Support.

Summary

tried updating the pipeline to the newest version of the SF CLI but now getting another error and the messaging just isn't clear - also there was a custom plugin created that I have no idea how to update

Steps To Reproduce

IMPORTANT Provide a repository that's configured to reproduce the issue. If you are unable to provide a repo, please explain why not. The more info we have from the start, the faster we can resolve your issue. We may close your issue if you don't include proper instructions.

  • Generate a project with sf project generate or fork dreamhouse-lwc.
  • Provide detailed step-by-step instructions on how to reproduce the issue. I create a merge request - it just runs but fails on the run-tests step

Expected result

Actual result

System Information

PASTE_VERSION_OUTPUT_HERE

Additional information

This is the current version of the yaml file: image: "node:latest" cache: key: ${CI_COMMIT_REF_NAME} paths:

#

GitLab CI/CD Pipeline for deploying DreamHouse App on Salesforce DX

# before_script:

Clone salesforce server key repository

stages:

#

Check code quality

# code-quality: stage: code-quality allow_failure: false script:

#

Run tests

# run-tests: stage: run-tests script:

install dependency plugin

  - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/g-minds/SalesForce/sfdx-gm-plugin.git
  - cd sfdx-gm-plugin
  - npm install
  - cd ..
  - sf plugins link sfdx-gm-plugin
  # Authenticate to the Dev Hub using the server key
  - sf org login jwt --client-id $SF_CONSUMER_KEY --jwt-key-file salesforce-ci/assets/server.key --username $SF_USERNAME --set-default-dev-hub --alias HubOrg
  # Create scratch org and install depenencies
  - sfdx gm:org:create -a $SCRATCH_ORG_ALIAS -d 1 -r https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/g-minds/SalesForce/salesforce-mdapi-converted.git -w
  - sf org display --target-org $SCRATCH_ORG_ALIAS

  # Push source to scratch org (This is with source code, all files, etc)
  #- sfdx force:source:push --target-org $SCRATCH_ORG_ALIAS
  - sf project deploy start --source-dir force-app --target-org $SCRATCH_ORG_ALIAS

  # Unit Testing
  - sf apex run test -y --target-org $SCRATCH_ORG_ALIAS --wait 30 --result-format human --code-coverage --test-level $TESTLEVEL
  - sf org delete scratch -p --target-org $SCRATCH_ORG_ALIAS
only:
- merge_requests
- develop
- master
- taxonomy

This is where the job fails (log attached): $ cd .. $ sf plugins link sfdx-gm-plugin (node:1773) Warning: Deprecated environment variable: SFDX_USE_GENERIC_UNIX_KEYCHAIN. Please use SF_USE_GENERIC_UNIX_KEYCHAIN instead. (Use node --trace-warnings ... to show where the warning was created) (node:1773) Warning: Deprecated environment variable: SFDX_AUTOUPDATE_DISABLE. Please use SF_AUTOUPDATE_DISABLE instead. (node:1773) Warning: Deprecated environment variable: SFDX_DOMAIN_RETRY. Please use SF_DOMAIN_RETRY instead. (node:1773) Warning: Deprecated environment variable: SFDX_LOG_LEVEL. Please use SF_LOG_LEVEL instead. @salesforce/cli: Linking plugin sfdx-gm-plugin... done $ sf org login jwt --client-id $SF_CONSUMER_KEY --jwt-key-file salesforce-ci/assets/server.key --username $SF_USERNAME --set-default-dev-hub --alias HubOrg (node:1808) Warning: Deprecated environment variable: SFDX_USE_GENERIC_UNIX_KEYCHAIN. Please use SF_USE_GENERIC_UNIX_KEYCHAIN instead. (Use node --trace-warnings ... to show where the warning was created) (node:1808) Warning: Deprecated environment variable: SFDX_AUTOUPDATE_DISABLE. Please use SF_AUTOUPDATE_DISABLE instead. (node:1808) Warning: Deprecated environment variable: SFDX_DOMAIN_RETRY. Please use SF_DOMAIN_RETRY instead. (node:1808) Warning: Deprecated environment variable: SFDX_LOG_LEVEL. Please use SF_LOG_LEVEL instead. (node:1808) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (node:1808) Warning: Closing file descriptor 18 on garbage collection (node:1808) [DEP0137] DeprecationWarning: Closing a FileHandle object on garbage collection is deprecated. Please close FileHandle objects explicitly using FileHandle.prototype.close(). In the future, an error will be thrown if a file descriptor is closed during garbage collection. Error: default level:INFO must be included in custom levels Cleaning up project directory and file based variables 00:00 ERROR: Job failed: exit code 1

github-actions[bot] commented 3 weeks ago

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

github-actions[bot] commented 3 weeks ago

Hello @GMlynda :wave: It looks like you didn't include the full Salesforce CLI version information in your issue. Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).

A few more things to check:

Thank you!

GMlynda commented 3 weeks ago

version was the most recent - run install in gitlab pipeline via npm command: npm install @salesforce/cli --global

GMlynda commented 3 weeks ago

gitlab-ci-master.txt I think I've got the yaml file attached now - not sure what else I need to change to get this work

GMlynda commented 3 weeks ago

ok, fixed Environmental Variables and I got further but now I'm getting the same SHA mismatch error again: Error (1): Metadata API request failed: An internal error caused this command to fail. isomorphic-git error: SHA check failed! Expected 2c75a36d67d49f7b3ff0d4df81ca73af3d906095, computed f75b07721a53832b21ed837c7589cb71b3a784c8 Cleaning up project directory and file based variables 00:00 ERROR: Job failed: exit code 1

shetzel commented 3 weeks ago

What is the CLI issue you're reporting? From your last post I see this error:

Error (1): Metadata API request failed: An internal error caused this command to fail. isomorphic-git error:
SHA check failed! Expected 2c75a36d67d49f7b3ff0d4df81ca73af3d906095, computed f75b07721a53832b21ed837c7589cb71b3a784c8

That could result from a deployment using an older version of the CLI. Recent CLI versions have fixed this error. I would ensure that the version of the CLI is indeed latest as you state: npm install @salesforce/cli --global. Before running commands I would output the result of running sf version --verbose and make sure it's what you expect. What was the command run to cause that error?

When updating from an older CLI (sfdx v7 or sf v1) to the latest I would reference this doc: https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_move_to_sf_v2.htm and this doc: https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_migrate.htm

If you're using a custom plugin and linking it to your installed CLI then I would ensure it's been updated to work with the latest Salesforce CLI versions and plugins. Ensure the plugin is built either before or after linking it.

GMlynda commented 3 weeks ago

Pretty sure at this point its because the custom plugin is not using the most recent version of the CLI but I'm not figuring out how to update it to get it there so I'm pretty stuck and at this point we're probably going to have to just release everything from the unlocked packages in our org so I can do deployments via the CLI until I get GearSet up and running. Unless you cam recommend someone I can reach out to who is familiar with moving custom plug in to the newer CLI cuz I'm not familiar with what it was written in or how to update it.

k-capehart commented 3 weeks ago

@GMlynda Is this the plugin that's failing: sfdx-gm-plugin? Is that internal? Do you know what it does? Maybe worth removing it from your workflow or finding an alternative.

GMlynda commented 3 weeks ago

yes that's the plug in - it is internal (but was created way before I got here in January). I know it creates the scratch org and then makes sure the source and the source for those packages listed as dependencies in the package.json are installed in it - if I understand how to do that latter part using just commands in the SF CLI I could probably do without it but I haven't been able to figure that part out.

GMlynda commented 3 weeks ago

sorry I mean the sfdx-project.json

k-capehart commented 3 weeks ago

I'm fairly certain you can do all that with sf org create scratch.

GMlynda commented 3 weeks ago

100% certain the sf org create scratch gives me a shell and I have to get the source code for each package I need in it and since each of the different packages has different dependencies (with are in the sfdx-project.json but don't include the installationkey for them) that I need some kind of plug in to help me but I'm really not understanding how to use those - plus this all has to be in the yaml file (or in a plug in that can be run from the yaml file for gitlab pipelines)

shetzel commented 3 weeks ago

If the error you reported is coming from your internal plugin then this isn't a CLI issue; it's a plugin issue.

There are 2 approaches I can think of.

  1. Update the plugin and what it does to use newer library versions, etc. Without any insight into what it does I can't help much except point you to docs. E.g., https://github.com/salesforcecli/cli/wiki/Migrate-Plugins-Built-for-sfdx. Based on that error, I'm guessing the plugin does a deployment possibly using one of our older core CLI plugins, @salesforce/plugin-source. If that's the case, use @salesforce/plugin-deploy-retrieve instead.
  2. As @k-capehart mentioned, don't use the internal plugin and instead do similar actions in the CI script using core CLI plugins or some other publicly available plugin. A good list can be found by running sf plugins discover.
github-actions[bot] commented 2 weeks ago

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.