Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

GitLab NPM Scope adds second @ in orchestrator:release #1200

Closed
dschibster opened this issue Jan 23, 2023 · 8 comments
Closed

GitLab NPM Scope adds second @ in orchestrator:release #1200

dschibster opened this issue Jan 23, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@dschibster
Copy link

dschibster commented Jan 23, 2023

Describe the bug
After checking at multiple junctures what the issue may be, I have come to the conclusion that the failure in our pipelines could only stem from the duplicate @ that is prepended to the npm_scope, because I could verify that the artifact exists, and at all other places I was not able to find any traces. #1168 already had such a failure, but only publish.ts was fixed as a hotfix. It seems more than publish is affected.

To Reproduce
Steps to reproduce the behavior:

  • Update a Package using orchestrator:publish
  • Create a Pipeline for manual-release
  • Run a Pipeline for Staging or whatever Instance is chosen as the first one.

Expected behavior

Artifacts should be found and released to target Instance

Screenshots

image

Platform Details (please complete the following information):

  • OS: Using the Docker Image provided at ghcr.io/dxatscale/sfpowerscripts
  • Version [e.g. CLI Version eg: 1.6.6]: 20.2.11
  • Salesforce CLI(sfdx cli) Version: 1.179,9
  • CI Platform: GitLab

Additional context
Probably a follow up issue to #1168 as more than one script uses npm scope in a similar way to publish. For me, it happens when running the release command.

@github-actions github-actions bot added the analysis To be decided on how to solution/fix label Jan 23, 2023
@vuha-acn
Copy link
Contributor

@dschibster - To fix the error, I have done the following in the in the default section:

  1. Added the "@" manually in the writing of the .npmrc file at the top for default
  2. Removed the "@" for the variable --scope "$NPM_SCOPE"

I'll be updated the dxatscale-templates soon to reflect this and corresponding documentation.

default:
   image: ghcr.io/dxatscale/sfpowerscripts
   # Generate NPM Configuration File for Package Registry Publishing
   before_script:
    - sfdx auth:sfdxurl:store -f "$DEVHUB_SFDX_AUTH_URL" -a "$DEVHUB_ALIAS"
    - echo "@${NPM_SCOPE}:registry=https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" >> .npmrc
    - echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc 
    # Below setting is required to push git tags and changelog to the repo      
    - git remote set-url --push origin https://gitlab-ci-token:${PROJECT_ACCESS_TOKEN}@$CI_SERVER_HOST/$CI_PROJECT_PATH.git

@dschibster
Copy link
Author

@vuha-acn Thanks for the heads-up but that doesn't do it for me. None of the --scope variables had an "@" to begin with. I did change the line you changed in the before_script, but at the end of it I still found it tried to pack @@salesforce-app/....

@dschibster
Copy link
Author

image
Going a little further, removing the "@" altogether will give me the correct npm-scope (as it only has one @), but the npm pack command still adds another one, because I think it expects the npm-scope to be without the prepended "@".

@vuha-acn Can you make something of that?

@dschibster
Copy link
Author

For the time being I was able to fix this by hard-coding the scope in both the before_script (with @ prepended) and in the --scope variables. For our current use case the single scope should be enough but I would appreciate a long-term fix that addresses this.

@vuha-acn
Copy link
Contributor

Yes, i've only hardcoded the '@' item below and removed any '@' on my NPM_SCOPE in my GitLab pipeline for CI/CD. That is basically the workaround now until we have time to investigate further.

- echo "@${NPM_SCOPE}:registry=https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" >> .npmrc

Glad you were able to get a short term work around in place.

@azlam-abdulsalam azlam-abdulsalam self-assigned this Jan 25, 2023
@azlam-abdulsalam azlam-abdulsalam added bug Something isn't working and removed analysis To be decided on how to solution/fix labels Jan 25, 2023
@dschibster
Copy link
Author

After Realizing that my NPM_SCOPE variable did actually have an @ I didn't ask for, your workaround now also does the trick. So the script adjustment with prepending the @ to the before_script is the only adjustment I needed to make in the end.

@vuha-acn
Copy link
Contributor

Glad that was the case. The workaround works for me as I've been using GitLab for my pipelines for few projects and that is the current fix until we get a more long term fix in place. I'm working on updating the dxatscale-template just strapped for time recently.

azlam-abdulsalam pushed a commit that referenced this issue Jan 31, 2023
users may pass in '@' or without '@' as the scope. sfpowerscripts need to handle it in bothways
across. A recent update broke this functionality

fix #1200
@azlam-abdulsalam
Copy link
Contributor

Fixed in Jan 23

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants