I have my .gitlab-ci.yml file set up in the typical three stages: test, build, deploy. During the build stage, I run a command that compiles my project and puts it in a tarball. The build stage appears to execute successfully because it moves on to the deploy stage, but the deploy stage then says it can't find the tarball. Is it in another directory? What happened to it? Thanks.
-
1Related https://about.gitlab.com/2016/03/10/setting-up-gitlab-ci-for-ios-projects/ You can create `artifacts: paths: `. Which allows later on for a download. – Unapiedra Apr 20 '16 at 18:02
-
Yeah, I'm pretty sure that was added after I posted this. – sajattack Apr 30 '16 at 19:56
2 Answers
For each test gitlab-ci clean the build folder, therefore the output files of the build stage are not available in the deploy stage.
You need to rebuild your project also in the deploy stage.
The "stages" are only useful to order your tests, i.e. avoid to try to do a deploy test if a build test failed.
EDIT: Since Gitlab 8.6, it is possible using dependencies feature

- 652
- 5
- 8
-
Weird. Would it be better to put the compilation in a seperate job? What's the DRY way to do this? – sajattack Oct 29 '15 at 17:24
-
Oh yes, it would be better, but **at this time** you can not reuse outputs from others stages/tests. – jeremf Nov 02 '15 at 14:14
I was surprised to see the same behaviour (on GitLab 8.4).
I use cmake
to create makefiles, then make
to build, and then make test
to run the test. I run all these in a build/
directory.
I don't want to repeat myself and identify easily which steps are failing. As such, I've created different gitlab-ci stages: cmake
, make
, test
, etc. I then tell gitlab-ci to keep the build
directory using the cache
option:
cache:
key: "$CI_BUILD_REF_NAME"
untracked: true
paths:
- build/
I think that the key
option will keep the same build directory for all stages acting on the same branch. See the gitlab-ci doc here: http://doc.gitlab.com/ce/ci/yaml/README.html#cache
EDIT: Don't use the cache
for this! GitLab implemented reusable artifacts between stages in 8.4: https://gitlab.com/gitlab-org/gitlab-ce/issues/3423
The CI runners will have to be adapted to support this. See: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/336

- 2,829
- 3
- 31
- 45
-
I came back to post #3423 but I see you already did. +1. It looks like the feature has been pushed back a few times though. – sajattack Mar 23 '16 at 17:36