Response is different when executed in Runner and Local

Response is different when executed in Runner and Local

Describe your question in as much detail as possible:

We’re including new pipelines in our private Gitlab runner that requires a request to the API server.
Each request received an empty response from the API server.

Request: curl -Ss --header "PRIVATE-TOKEN: $ACCESS_TOKEN" --request GET "https://$CI_SERVER_HOST/api/v4/projects"

Response:  []
Request: curl -Ss --header "PRIVATE-TOKEN: $ACCESS_TOKEN" "https://$CI_SERVER_HOST/api/v4/projects/${CI_PROJECT_ID}/repository/tags"

Response: {"message":"404 Project Not Found"}

But using the same command locally returns the expected response.

The .gitlab-ci.yml looks like this:

pre-merge-checks:
  stage: pre-merge-checks
  image:
    name: dwdraju/alpine-curl-jq:latest
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  script:
    - echo "Comparing Galaxy version from MR and Master"
    - MR_VERSION=$(grep 'version' galaxy.yml | awk '{print $2}')
    - 'curl -Ss --header "PRIVATE-TOKEN: $ACCESS_TOKEN" --request GET "https://$CI_SERVER_HOST/api/v4/projects"'
    - 'curl -Ss --header "PRIVATE-TOKEN: $ACCESS_TOKEN" "https://$CI_SERVER_HOST/api/v4/projects/${CI_PROJECT_ID}/repository/tags"'

Gitlab server: 15.0.3-ee
GitLab API v4
Gitlab Runner: 15.0.0

Hi @xAch :wave: :slightly_smiling_face:

I have a couple of questions:

  • the examples you provided are the ones you get when running from the command line or from the runner? My guess is that those are the runner’s output, but I want to be sure :slightly_smiling_face:
  • are you using the same private access token when testing both locally and on the CI pipeline?

Hi @zillemarco ! :wave:

Yes, the examples are from the runner when it was executed in the pipeline. When I run the same command locally with the same private access token and command, the response was the expected result. The access token is working as expected in the runner since this command works as expected:

git push --tags http://root:$ACCESS_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:master

So far the issue only happened when accessing the API endpoints in the runner.

Mmmmm…I thought it could have been related to the token not having enough permissions but it it’s the same token then it shouldn’t work even locally :thinking: