Cannot get artifact from upstream project from downstream =>404 Project Not Found

Hi,

I have an upstream private project where I have:

in .gitlab-ci.yml of the upstream project:

my_upstream_job:
  stage: build
  script:
     ...
     - tar cvf artifact.tar public/*
  artifacts:
    paths:
      - artifact.tar

and in the downstream one:

downstream_job:
   stage: deploy
   script:
      - curl --location --output artifacts.tar https://gitlab.com/api/v4/projects/<my_upstream_project_id>/jobs/artifacts/master/download?job=my_upstream_job&job_token=$CI_JOB_TOKEN

If I look into artifacts.tar, I have:

 $ cat artifacts.tar
 {"message":"404 Project Not Found"}

Typing part of the url (up to the project id) into the browser where I am logged into Gitlab, return correct json information but using another browser not logged, I get the exact same message.

So I guess I am missing or using bad credential.

I have based my sought on this page:

https://docs.gitlab.com/ee/api/jobs.html#get-job-artifacts

If you have suggestion or better the solution ! This will save the remaining hair from my head :slight_smile:

Regards,
Fabien

I reply to myself.
Even if it is not really clear, it seems the CI_JOB_TOKEN is only activated for higher gitlab subscription. I am using standard gitlab.com access.

Another way to do it, would be to store the artifact into git pages of the upstream job and then pull it from the downstream job. This way no more credential to use.

Before Gitlab 13.7:
There should be issues to download upstreams jobs’ artifacts directly, the documents are not clear and not work.
Please check: https://gitlab.com/gitlab-org/gitlab/-/issues/25071
The submitter also gave a workround bash script in the description.
After Gitlab 13.7, follow the documents: https://docs.gitlab.com/ee/ci/yaml/README.html#artifact-downloads-to-child-pipelines
It should use below section in downstream pipeline:

use-artifact:
  script: cat artifact.txt
  needs:
    - pipeline: $PARENT_PIPELINE_ID
      job: create-artifact