A BuildPostCommitSpec holds a build post commit hook specification. The hook executes a command in a temporary container running the build output image, immediately after the last layer of the image is committed and before the image is pushed to a registry. The command is executed with the current working directory ($PWD) set to the image’s WORKDIR.
The build will be marked as failed if the hook execution fails. It will fail if the script or command return a non-zero exit code, or if there is any other error related to starting the temporary container.
There are five different ways to configure the hook. As an example, all forms below are equivalent and will execute rake test --verbose .
1. Shell script:
"postCommit": {
"script": "rake test --verbose",
}
The above is a convenient form which is equivalent to:
"postCommit": {
"command": ["/bin/sh", "-ic"],
"args": ["rake test --verbose"]
}
2. A command as the image entrypoint:
"postCommit": {
"commit": ["rake", "test", "--verbose"]
}
Command overrides the image entrypoint in the exec form, as documented in
Docker: https://docs.docker.com/engine/reference/builder/#entrypoint.
3. Pass arguments to the default entrypoint:
"postCommit": {
"args": ["rake", "test", "--verbose"]
}
This form is only useful if the image entrypoint can handle arguments.
4. Shell script with arguments:
"postCommit": {
"script": "rake test $1",
"args": ["--verbose"]
}
This form is useful if you need to pass arguments that would otherwise be
hard to quote properly in the shell script. In the script, $0 will be
"/bin/sh" and $1, $2, etc, are the positional arguments from Args.
5. Command with arguments:
"postCommit": {
"command": ["rake", "test"],
"args": ["--verbose"]
}
This form is equivalent to appending the arguments to the Command slice.
It is invalid to provide both Script and Command simultaneously. If none of the fields are specified, the hook is not executed. |