Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitlab ci: Pass artifacts from two jobs of the same stage

Having some multiple jobs (not in parallel) and I'm trying to pass artifacts from the first job to the second one.

Here what it's look like:

    deploy-build-docker 1/2:
      stage: deploy
      image: docker:stable
      script:
      - ...
      artifacts:
        paths:
        - path

    deploy-preprod 2/2:
      stage: deploy
      image: alpine
      dependencies: [deploy-build-docker]
      script:
      -  ....

CI can't find dependencies, and give me this error deploy-preprod 2/2 job: undefined dependency: deploy-build-docker

I also tried deploy, deploy-build-docker 1/2 but I still have the same issue.

So how can i do that? Should I must do the build in another stage?

like image 953
Dr Claw Avatar asked Oct 24 '25 18:10

Dr Claw


1 Answers

Yes, you can only pass artifacts from previous stages.

By default, all artifacts from all previous stages are passed, but you can use the dependencies parameter to define a limited list of jobs (or no jobs) to fetch artifacts from.

To use this feature, define dependencies in context of the job and pass a list of all previous jobs from which the artifacts should be downloaded. You can only define jobs from stages that are executed before the current one. An error will be shown if you define jobs from the current stage or next ones.

https://docs.gitlab.com/ee/ci/yaml/#dependencies

Although they might add support for needs: in future to reference jobs in the current stage: https://gitlab.com/gitlab-org/gitlab/issues/30632

like image 116
Ivan Avatar answered Oct 27 '25 01:10

Ivan