Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab CI: Cannot find output of build stage

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.

like image 608
sajattack Avatar asked Oct 29 '15 09:10

sajattack


People also ask

Why is my GitLab runner not picking up jobs?

You can also check if your runner is allowed to run untagged jobs - you can do that under Admin and then edit it to see if that option is enabled. The runner is a specific runner for the project and not a shared one.

How do I find out why pipeline failed?

Get logs to diagnose problems You can view logs by navigating to the pipeline run summary and selecting the job and task. If a certain task is failing, check the logs for that task.

Why is GitLab pipeline failing?

It might be a security vulnerability The code in your most recent commit could be vulnerable, or a dependency could be at risk, either of which would trigger a failed security test and thus a failed pipeline.

What is Ci_project_dir?

CI_PROJECT_DIR. all. all. It defines the full path of the cloned repository, where the job is run.


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

like image 185
jeremf Avatar answered Oct 27 '22 17:10

jeremf


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

like image 45
big_gie Avatar answered Oct 27 '22 17:10

big_gie