CI_PULL_REQUEST not present


#1

Hi, it appears the CI_PULL_REQUEST variable is not available on the 2.0 platform. Is this known? Is there a work around for this? We need it for an automated code review tool we’re using. Thanks!


#2

#3

Yeah CI_PULL_REQUEST isn’t even listed :confused:


#4

This is a pretty reasonable request. I’ve opened an internal feature request for this.


#6

Does the existence of $CIRCLE_COMPARE_URL help at all? If it’s null, there is no pull request.


#7

Unfortunately no. The reason we need the exact PR URL is to review the PR details and also post comments. I’ve added this for the time being:

      if [ -z "${CI_PULL_REQUEST:-}" ]; then
      export CI_PULL_REQUEST=$(curl -s -X GET -u ${DANGER_GITHUB_API_TOKEN}:x-oauth-basic "https://api.github.com/repos/timberio/odin/pulls?head=timberio:${CIRCLE_BRANCH}" | jq -r ".[0].html_url")
      fi

#8

I hope that works for now. We will definitely support this in the future.


#9

$CI_PULL_REQUEST(S) is now supported. However, we’d recommend using $CIRCLE_PULL_REQUEST(S) for the consistency with other env vars in 2.0.


#10