$CIRCLE_PULL_REQUEST is missing from my Pull Request

Overview

When you first publish your commit to your VCS, the webhook will fire and CircleCI will download your code and run your project. In some cases this environment variable may not appear. Here are a few scenarios 

Only Build Pull Requests

When you create the pull request, a new commit ID is generated and you might expect this to run on CircleCi again, but it will not.We do not run code twice that hasn't been modified to save you time, resources, and money. If the tests have already passed, there is no reason to test the code again. What will happen is the original job run on your account will be updated to show that it is now a pull request.

In the original run of the job, before it was a pull request, data such as `$CIRCLE_PULL_REQUEST` will not exist. Then after you create the pull request and the job on CircleCi is updated to reflect that, the data will be present if the job is re-run.

In the `Advanced Settings` page of your project's settings you can enable `Only build pull requests`

This will only allow commits to `Master` (your default branch), and pull requests to be run. This will resolve the issue above as the first commit will not be run, so when the pull request is created it can run properly.

GitHub Apps Integration

If your organization uses the GitHub Apps integration of CircleCI the $CIRCLE_PULL_REQUEST environment variable will not be present as the GH Apps integration does not support this functionality at this time.

 

Additional Resources

 

Was this article helpful?
6 out of 27 found this helpful

Comments

0 comments

Article is closed for comments.