Thinking about CI and trying to get the right mental model. Specifically I am trying to understand the function of the “when” keyword, in light of “stages” behavior.
My understanding is that only items specifically identified with the artifacts keywords are preserved between jobs of a stage and jobs of a successive stage (for example, between build and test stages). Likewise, I remember reading somewhere that jobs within a stage can (and will) be run simultaneously on multiple machines, and thus there is no sequencing of jobs within a stage.
In light of this, I am confused by http://docs.gitlab.com/ce/ci/yaml/README.html where it provides an example of the use of the “when” keyword. Any cleanup one might do in “cleanup_build_job” after the “build” stage there would seem to be moot. likewise, is there any guarantee that cleanup_build_job is run on the same (all) runners that build_job is run on and failed? By then the job “build_job” would have completed, and artifacts zipped up (on success only?) and moved back to the gitlab server. The only utility I could see for an on_failure is in freeing up disk space on the (shell) runner so that the build of other projects would not be impacted by disk space use.
Am I correct in this? Or is there a utility in “when: on_failure” and “when on_success” that I am missing? Have I mis-interpreted something about how (shell) runners work?