Cannot access project variable value from command

Hi!

I’m calling the the APIv2 with a cURL command to trigger a parametrised build. For this, I have a user-level access token set as project level env variable. However, the variable does not resolve correctly when used. Here’s the code:

commands:
  lfs_checkout:
    description: Checkout lfs in addition to code
   ...
      - run:
          name: Trigger dependant code builds
          command: |
              curl -v -H 'Circle-Token: "'"$CIRCLECI_TOKEN"'"' --header "Content-Type: application/json" -d '{
              "branch": "'"$CIRCLE_BRANCH"'", "parameters": { "checkout_complete": true }}' \
               https://circleci.com/api/v2/project/github/company/backend/pipeline

As a result, I get a ‘project not found’ from the API, but this works well when I hardcode the token. Fun fact is that $CIRCLE_BRANCH resolves correctly. I know the variables are redacted in the logs, I’ve played with variable quoting in different ways. I also assumed variable exposure can be disabled for branches (not forked, normal) but there is no option for this.
But in my case it doesn’t work at all. Any clue how to deal with this?

Additional question: any way to trigger APIv2 with a non-personalised token?

Hi @qugu, and welcome to the CircleCI community!

I replied to the Support ticket you submitted but also wanted to share some information here.

This post has examples on how to proceed to ensure proper interpolation.

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