Pull Request Environment Variables

We are trying to determine if individual builds are started based on a PR. In the CircleCI UI, we can see that the build is associated with a PR, but none of the PR environment variables are present (e.g. CIRCLE_PULL_REQUEST, CIRCLE_PR_NUMBER, etc…). We have setup a workflow with multiple stages and would like to filter some jobs/stages base on if it is a PR build.

Is there some setting in CircleCI or GitHub that I need to set in order for these values to be included in the CircleCI environment variables?


In the example above, it should have a CIRCLE_PR_NUMBER=4 and a valid PR URL in CIRCLE_PULL_REQUEST.

Hi @vonnagy The CIRCLE_PR_NUMBER is only available for forked PRs. More on this can be found on the Built-in Environment Variables documentation.

The CIRCLE_PULL_REQUEST url should be present on commits after the PR is opened.

For example, if there is a commit that is built on CircleCI, then the PR opened afterwards, the url will not be present. However, every subsequent commit to the PR will have the CIRCLE_PULL_REQUEST url present.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.