"Project not found" when using Orb

I’m using trigger-workflows-for-all-modified in the Swissknife Orb so that I can conditionally deploy builds in my monorepo.

The orb activates correctly and tries to trigger deploys when relevant directories have been changed. But it’s not able to execute the required workflow.

Here is the workflow in my config.yaml:

  trigger-needed-workflows:
    docker:
      - image: "circleci/node:12"
    working_directory: /home/circleci/project/
    steps:
      - checkout
      - swissknife/trigger-workflows-for-all-modified:
          base-branch: master
          vcs-type: bitbucket
          run-mode-for-base-branch: run_for_last_commit
          use-divergence-point: true
          code-param-name-map: '
            [
            {"regex": "^(app).*", "param_name": "run_app_workflow"},
            {"regex": "^(api).*", "param_name": "run_api_workflow"},
            {"regex": "^(public).*", "param_name": "run_public_workflow"},
            {"regex": "^(admin).*", "param_name": "run_admin_workflow"}
            ]'
          additional-param-map: '{"run_trigger_workflow": false}'
          use-swissknife-sha: true

Additionally I set the following environment variables:

  • CIRCLE_TOKEN : An API token I created for the project
  • CIRCLE_PROJECT_USERNAME : Using same as: app.circleci.com/pipelines/bitbucket/[username]
  • $CIRCLE_PROJECT_REPONAME : Using same as: app.circleci.com/pipelines/bitbucket/[username]/[reponame]

The output in circleci says that it’s trying to execute the following API call:

  curl --silent -X POST \
    "https://circleci.com/api/v2/project/bitbucket/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline?circle-token=${CIRCLE_TOKEN}" \
    -H 'Accept: */*' \
    -H 'Content-Type: application/json' \
    -d '{
      "branch": "'$CIRCLE_BRANCH'",
      "parameters": '$custom_params'
    }'

And here is the error message:

Calling Circle CI for branch: master with params
{"run_trigger_workflow":false,"swissknife_sha":"[SHA]","run_api_workflow":true}
{
  "message" : "Project not found"
}

Is there any way to work out why it’s not able to find the project?

Is it possible the environment variables aren’t being passed through?

Any help would be appreciated.

Hello,

Are you able to run that API call locally and manually enter the fields? If you run that curl locally with all the fields populated correctly and it still fails I would suspect it’s an auth issue, You could try generating a new auth token in your user settings page and see if the request works locally with the new auth.

Thanks for the help. That did indeed help me work out the problem.

It turns out that the API call wasn’t working because I was using a project token instead of a personal token (project tokens don’t appear to be supported in v2).

It would be good if the error message was better than “Project not found”. Something like “invalid token” would be good. Though I suppose for security reasons the cause of the error might be obscured.