I have a job in YAML script that consists of compiling, testing and uploading the results. Part of this job which is the testing takes a long time. I tried to separate that task into three sub tasks for compiling, running the tests and uploading results.
In such setup I could separate tests into 3 parallel parts and run the whole build faster.
However I recognised that both the build directory and the gradle cache directory are cleaned up between jobs. It basically means I have to recompile on each job. The overhead of recompiling each time is so high that the overall run time will only increase.
Is it possible to disable this behaviour? like dedicating a directory to each commit and share it between jobs?
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
Assuming you're using docker runners, you need to use volumes to keep directories between builds. Everything else is destroyed; that's part of the point.
I tried this approach and it will not work. the problem is that if I mount a volume on the build path, all the builds will share the same context. I can not change the code checkout directory as the check out happens before anything from YAML file is executed. And even if I overcome all the above mentioned problems, I think removing build and temp directories is kind of hardcoded in runner, as I can see these line on very beginning of each build log after docker images are pulled successfully:
running gitlab 8.2.1 and runner 0.7.2, I have no success using cache for this
purpose.
maybe there is a misunderstanding about what I meant here. I want one "job" in a build process to do compilation and the next "job" to use compiled files for running tests and so on.
following is the part of my build script that should do this:
I had this problem too but I think it stems from a fundamental misunderstanding of the cache feature. What I (and, I think @mohamnag) want it to do is cache files between jobs of the same build. But what it does is cache files between builds of the same job.
In this example, AssembleCode, RunTests and PreserveArtifacts each have their own completely independent caches which are restored before each run. Whats more each branch has its own set of caches meaning if you tend to only push to each branch once when creating a merge request, your cache will almost always be empty.
@tamlyn yes, what I meant (from the first ticket) was caching between jobs of the same build.
I used to use Bamboo, and it had a pretty similar feature, so a job consisting of multiple steps could share artifacts between steps. The new cache feature however does not seem to do the this.
I have currently solved my problem by mounting an extra volume and copying shared artifacts between jobs to that one, but it could have been more transparent.
I agree with @mohamnag as well. If dependencies are generated in one step these dependencies are not available in the next step. It would be beneficial if they were.
Let's don't mix the caching with passing artifacts between stages.
Caching is not designed to pass artifacts between stages. You should never expect that you have the cache present. I will make the cache more configurable making it possible to cache between any jobs or any branch or anyway you want :) Cache is for runtime dependencies needed to compile the project: vendor/?
Artifacts are designed to upload some compiled/generated bits of the build. We will soon introduce the option (on by default) that artifacts will be restored in builds for next stages.
I'm facing an issue where creating/extracting the cache takes up longer than the build time itself due to the size of the generated files. Having the option to tell the ci not to clean up between jobs instead of caching would definitely save me a lot of time! I'm talking 20+ mins wasted on creating the cache, then extracting it in the next job.