Skip to content

Artifacts are not passed between dependent stages

Summary

I have a pipeline comprised of two stages (build and deliver), each of which has a single job. The build stage builds a Debian package, and the deliver stage is supposed to build a Docker image which installs the Debian package among with other applications. However, although the build stage is set as a dependency of the deliver stage and the Debian package is successfully built, the Debian package file is not accessible from the deliver stage, thus the deploy stage fails.

Steps to reproduce

(How one can reproduce the issue - this is very important)

Example Project

Here are the contents of .gitlab-ci.yml:

image: ubuntu:18.04

variables:
  DOCKER_IMAGE: $CI_REGISTRY_IMAGE:$CI_PIPELINE_ID

services:
  - docker:dind

stages:
  - build
  - deliver

build DEB package:
  stage: build
  script:
    - apt-get update && apt-get install -y build-essential dpkg gettext-base
    # output the DEB file to $CI_PROJECT_DIR
    - make -e PACKAGE_VERSION=$CI_PIPELINE_ID -e PACKAGE_BUILDDIR=$CI_PROJECT_DIR
    - cp $CI_PROJECT_DIR/package.deb .

deliver Docker image:
  image: docker:18.09
  stage: deliver
  dependencies: 
    - build DEB package
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build --pull=true --tag $DOCKER_IMAGE .
    - docker push $DOCKER_IMAGE

Here are the contents of the project's Dockerfile:

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y nginx dpkg
COPY package.deb .
RUN dpkg -i package.deb