Here are some examples of running custom hooks before and after the docker commands.
before("build", execute: "echo 'docker build before hook'", ) after("build", execute: "echo 'docker build after hook'", )
$ kubes docker build Running docker before build hook. => echo 'docker build before hook' docker build before hook => docker build -t gcr.io/tung-275700/demo:kubes-2020-10-10T20-06-28-2e80bf4 -f Dockerfile . Running docker after build hook. => echo 'docker build after hook' docker build after hook $
before("push", execute: "echo 'docker push before hook'", ) after("push", execute: "echo 'docker push after hook'", )
$ kubes docker push Running docker before push hook. => echo 'docker push before hook' docker push before hook => docker push gcr.io/tung-275700/demo:kubes-2020-10-10T20-06-28-2e80bf4 Running docker after push hook. => echo 'docker push after hook' docker push after hook $
By default, if the hook commands fail, then kubes will exit with the original hook error code. You can change this behavior with the
before("build" execute: "/command/will/fail/but/will/continue", exit_on_fail: false, )
The command name corresponds to the
docker commands: apply, delete, etc.
|label||A human-friendly label so you can see what hooks is being run.|
|execute||The script or command to run. IE: path/to/some/script.sh|
|exit_on_fail||Whether or not to continue process if the script returns an failed exit code.|
Instead of using a script for the hook
execute option, you can also use a Ruby object. This provides some more control over the current process. See: Ruby Hooks