Skip to content

Configuration Scripting

Evgeny Chugunnyy (John) edited this page Mar 11, 2024 · 2 revisions

Scripting support

Artipie provides custom scripting support. It allows running custom logic server-side without Artipie source code modifications. Artipie relies on the JVM scripting engine for this functionality.

Configuration

To run the script, add crontab section to Artipie main configuration file, then add the script as a key/value pair:

meta:
...
  crontab: 
    - path: path/to/script1.groovy
      cronexp: */3 * * * * ?

cronexp value here means 'every 3 minutes'. The value must be in crontab Quartz definition format

File extensions

Scrips must have a file extension corresponding to one of the supported scripting languages.

Scripting language File extension
Groovy .groovy
Python 2 .py

Accessing Artipie objects

Some Artipie objects could be accessed from the scripts. Such objects have names starting with underscore _. The table with available objects is given below.

Object name Artipie type
_settings com.artipie.settings.Settings
_repositories com.artipie.settings.repo.Repositories

Groovy snippet using Artipie _repositories objects, example:

File file = new File('/my-repo/info/cfg.log')
cfg = _repositories.config('my-repo').toCompletableFuture().join()
file.write cfg.toString()