0

I require my pipeline to download artifacts that are generated on my develop branch that are used as a basis for comparison in my tests in other branches.

Essentially my snapshots job that is run only on develop branch generates a bunch of snapshots that are used in the test stage on subsequent builds. It seems that the "needs:" directive is not working here and bombs out on a syntax error. Am I missing something?

error: jobs:test:needs:need project should be a string

Here is an extract of my .gitlab-ci.yml

snapshots:
  stage: snapshot
  dependencies:
    - build
  script:
    - yarn test:ci-update
  artifacts:
    paths:
      - 'test/integration/snapshots/*.png'
    expire_in: 4 week
  only:
    - develop

test:
  stage: test
  dependencies:
    - build
    - snapshots
  script:
    - ls -lha  test/integration/snapshots/reviewed-visual*
    - find test/integration/snapshots | grep reviewed-visual
    - yarn test:ci
  artifacts:
    paths:
      - test/integration/diffs/
      - dist/test/
    when: always
  needs:
    - job: snapshots
      artifacts: true
      ref: develop

Any help would would be supper appreciated.

Martin
  • 161
  • 1
  • 6

1 Answers1

1

Per the documentation, you need to use needs:project: for this and you must have a Premium subscription entitlement for it to work.

  needs:
    - project: $CI_PROJECT_PATH
      job: snapshots
      ref: develop
      artifacts: true

Alternatively, you can use the API to download artifacts as well. In GitLab Premium, you can do this with the builtin job token:

artifact_download:
  stage: test
  script:
    - 'curl --location --output artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/jobs/artifacts/develop/download?job=snapshots"'
sytech
  • 29,298
  • 3
  • 45
  • 86