Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab: How to use artifacts in subsequent jobs after build

I've been trying to make a GitLab CI/CD pipeline for deploying my MEAN application. I have three stages: 1. test 2. build 3. deploy

The build stage has a build_angular job which generates an artifact. Now I want to use this artifacts in the next stage i.e deploy. The deploy job tells me that it has downloaded the artifact(image has been attached), but now I want to extract this artifact, but I don't know where the artifact is being downloaded.

The path where the artifact is being downloaded is not mentioned anywhere in the docs. if

like image 200
Goutam B Seervi Avatar asked Jun 23 '19 06:06

Goutam B Seervi


Video Answer


1 Answers

GitLab is cleaning the working directory between two subsequent jobs. That's why you have to use artifacts and dependencies to pass files between jobs.

When the "deploy" job says that the build artifact have been downloaded, it simply means that they have been recreated as they were before. The location of the downloaded artifacts matches the location of the artifact paths (as declared in the .yml file).

Example

build_job:
  stage: build
  script:
  - echo "create bin/ directory"
  - make
  artifacts:
    paths:
      - bin/

deploy_job:
  stage: deploy
  script:
  - ls bin/
  dependencies:
  - build_job

Directory bin/ is passed to deploy_job from build_job.

like image 135
piarston Avatar answered Sep 18 '22 08:09

piarston