The CIRCLE_PR_NUMBER variable is only available on forked Pull Requests
You can find additional information here: https://circleci.com/docs/guides/security/env-vars/#built-in-environment-variables
Additionally, the CIRCLE_PULL_REQUEST environment variable will be populated on any build associated with any pull request. You can use the following syntax to extract out just the PR number:
${CIRCLE_PULL_REQUEST##*/}The value of CIRCLE_PULL_REQUEST environment variable is set to something like the following:
https://github.com/org/project/pull/1728
When you use the above syntax, the following is extracted from the CIRCLE_PULL_REQUEST environment variable :
1728