1

I'm trying to run this pipeline:

stages:
  – build
  – deploy

get_packer:
  stage: build
  artifacts:
    paths:
    – packer
  script:
    – echo "Fetching packer"
    – wget https://releases.hashicorp.com/packer/1.5.5/packer_1.5.5_linux_amd64.zip -O packer.zip
    - unzip -o packer.zip -d packer
    - cd packer
    - chmod +x packer

deploy_centos-7:
  stage: deploy
  script:
    – echo "Deploying CentOS 7"
    – cd packer
    – ./packer build centos/centos-7.json

Stage build completes successfuly but I get this at the deploy stage:

Reinitialized existing Git repository in /home/gitlab-runner/builds/c04fe5cf/0/project/pak/.git/
Checking out 43dsq6aa as refs/merge-requests/3292/head...
Removing packer.zip
Removing packer/packer

And obviously failed because

./packer: No such file or directory

I don't understand why this files fetched from build get removed?

  • Does this answer your question? [How can I pass artifacts to another stage?](https://stackoverflow.com/questions/38140996/how-can-i-pass-artifacts-to-another-stage) – aboitier Jan 05 '21 at 11:40

1 Answers1

0

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.

stages:
  – build
  – deploy

get_packer:
  stage: build
  artifacts:
    paths:
    – packer
  script:
    – echo "Fetching packer"
    – wget https://releases.hashicorp.com/packer/1.5.5/packer_1.5.5_linux_amd64.zip -O packer.zip
    - unzip -o packer.zip -d packer
    - cd packer
    - chmod +x packer

deploy_centos-7:
  stage: deploy
  dependencies:
    - build
  script:
    – echo "Deploying CentOS 7"
    – cd packer
    – ./packer build centos/centos-7.json
aboitier
  • 180
  • 11