nrwl / nx-orb

✨ A CircleCI Orb which includes helpful commands for running Nx commands in the CI
https://github.com/nrwl/nx-orb
MIT License
20 stars 25 forks source link

Calculating BASE SHA on master branch #47

Closed vikaskumr closed 1 year ago

vikaskumr commented 1 year ago

Orb version:

nrwl/nx@1.6.1

What happened:

I used nx/set-shas in my circleci deployment but by default by main branch is master and in circleci I always get Base SHA as null and the below error.

undefined:1
{:message "Project not found"}
 ^

SyntaxError: Unexpected token : in JSON at position 1
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (/home/circleci/project/index.js:138:35)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1334:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

Expected behavior:

Ideally it should return the Base SHA and Head SHA

Additional Information:

Here is the output of the Circleci

undefined:1
{:message "Project not found"}
 ^

SyntaxError: Unexpected token : in JSON at position 1
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (/home/circleci/project/index.js:138:35)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1334:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

Base SHA

Head SHA
4d59078a4a8c8e82c4a47a1258fa74064a1be522

NX_BASE and NX_HEAD environment variables have been set for the current Job
CircleCI received exit code 0

Any assistance you can provide is much appreciated. Thanks!

chiubaka commented 1 year ago

If you're using this with a private repo, very likely this issue is relevant: https://github.com/nrwl/nx-orb/issues/5

Make sure you're providing a CIRCLE_API_TOKEN environment variable, which contains a personal API Circle API token generated from your account settings. Project-scoped API permissions will not resolve the issue.

meeroslav commented 1 year ago

@vikaskumr did the suggestion from @chiubaka solve your issue?

wilkuintheair commented 1 year ago

@vikaskumr did the suggestion from @chiubaka solve your issue?

Hey @meeroslav, I've had the same issue as posted here and the suggestion from @chiubaka helped me :)

I've added CIRCLE_API_TOKEN environment variable with my token and it worked 🎉