После указания зависимостей Gitlab-CI
по-прежнему удаляет артефакт из рабочего каталога при переходе на следующий этап. Я пробовал все варианты этого кода, которые, как мне кажется, должны работать, но безуспешно. Кроме того, я читал об этом часами, но безуспешно.
Гитлаб 11.6.0
stages:
- build_app
- build_container
- test
- release
- deploy
variables:
IMAGE_TEST_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
IMAGE_RELEASE_NAME: $CI_REGISTRY_IMAGE:latest
build_app:
stage: build_app
script:
- echo "compile the program"
- zip zipfile.zip helloworld.txt
- pwd
- ls -al
artifacts:
paths:
- /zip
build_container:
stage: build_container
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
dependencies:
- build_app
script:
- pwd
- ls -al
- docker build --pull -t $IMAGE_TEST_NAME .
- docker push $IMAGE_TEST_NAME
test:
stage: test
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
script:
- docker pull $IMAGE_TEST_NAME
- docker run $IMAGE_TEST_NAME yum install unzip -y && unzip /helloworld.zip && cat /helloworld.txt
release:
stage: release
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
script:
- docker pull $IMAGE_TEST_NAME
- docker tag $IMAGE_TEST_NAME $IMAGE_RELEASE_NAME
- docker push $IMAGE_RELEASE_NAME
only:
- master
deploy:
stage: deploy
script:
- ./deploy.sh
only:
- master
when: manual
Ошибка от build_container
stage:
Running with gitlab-runner 11.6.1 (8d829975)
on gitrunner-shell trtHcQTS
Using Shell executor...
Running on gitrunner.example.com...
Fetching changes...
Removing zipfile.zip #################### <------------- this right here
HEAD is now at 07e787e Update .gitlab-ci.yml
Checking out 07e787ec as newFeature...
Skipping Git submodules setup
$ echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
WARNING! Your password will be stored unencrypted in /home/gitlab-runner/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
$ pwd
/home/gitlab-runner/builds/trtHcQTS/0/dhealy/docker-helloworld-test
$ ls -al
total 12
drwxrwxr-x 3 gitlab-runner gitlab-runner 80 Jan 22 12:10 .
drwxrwxr-x 4 gitlab-runner gitlab-runner 70 Jan 21 17:48 ..
-rw-rw-r-- 1 gitlab-runner gitlab-runner 57 Jan 22 12:10 dockerfile
drwxrwxr-x 5 gitlab-runner gitlab-runner 138 Jan 22 12:10 .git
-rw-rw-r-- 1 gitlab-runner gitlab-runner 1450 Jan 22 12:10 .gitlab-ci.yml
-rw-rw-r-- 1 gitlab-runner gitlab-runner 11 Jan 22 12:10 helloworld.txt
$ docker build --pull -t $IMAGE_TEST_NAME .
Sending build context to Docker daemon 151kB
Step 1/3 : FROM centos:7
7: Pulling from library/centos
Digest: sha256:184e5f35598e333bfa7de10d8fb1cebb5ee4df5bc0f970bf2b1e7c7345136426
Status: Image is up to date for centos:7
---> 1e1148e4cc2c
Step 2/3 : COPY zip/helloworld.zip /
COPY failed: stat /var/lib/docker/tmp/docker-builder929937870/zip/helloworld.zip: no such file or directory
ERROR: Job failed: exit status 1
Я ожидаю, что helloworld.zip
будет существовать в рабочем каталоге на следующем этапе, build_container
.