We are working on workspaces, a new way of sharing files within a build.
Workspaces allow jobs within a build to share files. They are useful when you want to use build artifacts from a previous job; for example, you create a cache that can be used in multiple jobs later.
create_workspace logic should probably run after before_cache: script.
In https://api.travis-ci.org/v3/job/560286391/log.txt (build link), I use a stage to build a shared dependency, then add the result to both cache and workspace. Before saving the cache, I clean up the directories from redundant data in before_cache:. As it is now, the workspace is saved with that redundant data.
@BanzaiMan, Iād like to confirm with you that my understanding of how workspace works is correct.
Letās say I have a simple 3-stage pipeline:
jobs:
include:
- stage: Build
script: # compiles sources
workspaces:
create:
name: shared
paths: .
- stage: Test
workspaces:
use: shared
script: # compiles tests, runs them and generates coverage reports
- stage: Scan
workspaces:
use: shared
script: # does analysis and collects other metrics
Am I right that both Test and Scan stages will use the shared workspace in read-only mode? In other words, Scan will not see any changes made by the Test stage, correct?
Thatās correct. If there is no reason for the Scan stage to wait for the Test stage to finish, you will save yourself some wall clock time by running them in the same stage.
The reason Iām having them separately is to provide better control over execution time. Also depending on the case, Iād like to run them in different groups: only (1) or (2), (1) and (2), all of them. Let me know if you see any problems with this.
I raised the question because after migrating from Travis shared caches to workspaces I accidentally broke the analytics on the Scan stage I guess the reason is clear know. Is it possible to update the workspace with the changes made on stage Test?
So far I tried the trick with two workspaces:
jobs:
include:
- stage: Build
script: # compiles sources
workspaces:
create:
name: compiled_sources
paths: .
- stage: Test
script: # compiles tests, runs them and generates coverage reports
workspaces:
create:
name: test_results
paths: .
use: compiled_sources
- stage: Scan
workspaces:
use: test_results
script: # does analysis and collects other metrics
And looks like it should be working, but now for each stage, I have two jobs:
(1) a new one which uses either compiled_sources or test_results workspaces
(2) the old one which uses the outdated shared workspace
Is that expected? How can I drop the shared workspace?
Note: I triggered the pipeline manually using the āTrigger a custom build (Beta)ā feature, could it be the reason?