Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set _authToken via pnpmCommand? #303

Open
antpaw opened this issue Feb 13, 2024 · 2 comments
Open

How to set _authToken via pnpmCommand? #303

antpaw opened this issue Feb 13, 2024 · 2 comments

Comments

@antpaw
Copy link

antpaw commented Feb 13, 2024

I'm looking for a way to do something like this. Does anyone know how I could set the token? I do not want to set it via project's .npmrc. Thank you!

  pnpmCommand.set(listOf("config set https://npm.pkg.github.com/:_authToken $authToken"))
@deepy
Copy link
Member

deepy commented Feb 13, 2024

Based on the constraints I'd recommend using an environment variable
https://pnpm.io/npmrc#url_authtoken
pnpm/pnpm#3141 (comment)

@antpaw
Copy link
Author

antpaw commented Feb 13, 2024

Thanks you for your reply!

i've tried two things, setting it the env with gradle.

val buildFrontend by tasks.registering(PnpmTask::class) {
    val version = project.property("version")
    environment.set(
        mapOf(
            "VITE_MY_VERSION" to version.toString(),
            "npm_config_//npm.pkg.github.com/:_authtoken" to authToken.toString()
        )
    )
    pnpmCommand.set(listOf("build:web"))
    dependsOn(tasks.pnpmInstall)

it still errors out on install with 401

> Task :frontend:pnpmInstall
Progress: resolved 0, reused 1, downloaded 0, added 0
 ERR_PNPM_FETCH_401  GET https://npm.pkg.github.com/some-pkg: Unauthorized - 401

and setting it directly in bash

$ export npm_config_//npm.pkg.github.com/:_authtoken=myToken            
export: not valid in this context: npm_config_//npm.pkg.github.com/:_authtoken

this errors out with not valid because of all the special chars like . and / right?

It looks like that the env example is only working for github actions? I'm running this on jenkins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants