How to define what files will be artifacts
Defining artifacts is a very simple operation.
To achieve this, you need to have a file named
rocketgit/
artifacts
inside your project directory.
You can keep this file in git or you can generate it at build time
- it is your choice.
The format of the file is:
local_path
map = where to map the file in the artifacts web space
content_type = put_here_a_content_type # optional
regex = \.(png|gif|jpg)$ # optional, used only if local_path ends with '/' (is a directory)
local_path is a file or a directory relative to the repository root
directory. Its use is to specify where to look for files.
If it is a directory, you must append a
/ char.
Indent the attributes with any amount of spaces/tabs.
The
map attribute will map your artifacts to a hierarchy which will be
available in
Artifacts section of your repository.
If the
map line ends with the '/' char, the original file name will
be appended to it. Else, the name will be changed.
For the
map line, you can use the following variables, which will
be replaced by their values:
- env - The environment string (example: debian-10-amd64)
- head - hash of the last commit (example: 58139c7a3b50e08815d5ae97dd6d15dcbfd96000)
- refname - reference name where the commits were pushed (example: ref/heads/main)
- refname_short - short reference name where the commits were pushed (example: main)
- hook_id - The id of the hook which triggered the build (example: 734)
- uid - The uid of the user which pushed (example: 34)
- original_path - the local_path string
- original_path_no_ext - the local_path string, but without extension
Variables must be enclosed between
@@ chars (example: @@env@@).
You can have as many
map lines as you need.
Optionally, you can add the
regex attribute to filter what files you
want to declare as artifacts. It makes sense when
local_path
is a directory.
If
regex is missing, all files will be processed.
Again optionally, you can also set a proper content type by adding
a
content_type attribute.
It is useful when someone will try to download your artifacts
to allow a proper application to be used to open the file.
If not specified, it will be auto-detected.
An example:
build/my_cool_script.sh
map = dir1/@@env@@/@@refname_short@@/
content_type = text/plain
build/my_docs.pdf
map = docs/@@refname_short@@/My new name.pdf
map = docs/latest/My new name.pdf
content_type = application/pdf
./
map = docs/@@refname_short/
regex = \.xyz$
content_type = application/xyz
The above example will upload the file
build/my_cool_script.sh
to the server in the directory
dir1/debian-10-amd64/main/my_cool_script.sh
(please note that the
build/ string is stripped).
Also, it will upload the file
my_docs.pdf in two places, changing
the name at the same time.
Finally, it will scan the root project directory (
./), select all files
with
.xyz extension and set the content type to
application/xyz.
Please note that the search is not recursive: only the files in the specified
directory are tested.