{:title "Artifacts" :category :builds :index 60 :summary "Learn how to use artifacts in order to share information between jobs, and make them available for download." :related [["caching" "Caching"] ["intro/basic-example" "Basic example"] ["intro/useful-example" "A more useful example"]]}
Job artifacts serve two purposes:
And jobs can do two things with artifacts: save them or restore them.
Jobs that create artifacts in order for other jobs to use them, or to make them
available for download, need to explicitly tell MonkeyCI where to find the
artifact files in question, and give them an id. This id will be used to refer
to them in other jobs. This is done using the save-artifacts function. For
example:
(def create-file
(-> (action-job
"create-file-job"
(fn [ctx]
(spit "test.txt" "This is an artifact file")))
(save-artifacts (artifact "some-id" "test.txt"))))
In this example we use the Clojure standard spit function
to write a string to a file. The artifact function is available to declare an
artifact, with an id and a location. The location is relative to the job working
directory, which is the checkout directory by default.
Jobs that want to use an artifact that has been generated by another job, must
indicate that to MonkeyCI. Both the id of the artifact, and where to restore
it has to be specified. For this, the restore-artifacts function is available.
Building further on the previous example, we could write another job that uses the saved artifact like so:
(def use-file
(-> (action-job
"use-file-job"
(fn [ctx]
(println "The artifact contents is:" (slurp "test.txt"))))
(restore-artifacts (artifact "some-id" "test.txt"))
(depends-on "create-file-job"))
We use the counterpart of spit, called slurp to read the file contents here.
Of course, this is a contrived example, but it illustrates the point. Also note
the explicit dependency declaration, more on that below.
Note that artifacts do not imply dependency. You still have to specify the job interdependencies explicitly. MonkeyCI will not warn you when a job wants to restore an artifact that is not being saved in the dependency chain (although we may add that as a feature later on). The artifact will simply not be available, and the job will probably fail.
So for MonkeyCI it's perfectly acceptable that an artifact is not available, it's up to the job itself to handle that situation.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |