Skip to content

build.v1.buildPostCommitSpec

"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.\n\nThe 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.\n\nThere are five different ways to configure the hook. As an example, all forms below are equivalent and will execute rake test --verbose.\n\n1. Shell script:\n\n \"postCommit\": {\n \"script\": \"rake test --verbose\",\n }\n\n The above is a convenient form which is equivalent to:\n\n \"postCommit\": {\n \"command\": [\"/bin/sh\", \"-ic\"],\n \"args\": [\"rake test --verbose\"]\n }\n\n2. A command as the image entrypoint:\n\n \"postCommit\": {\n \"commit\": [\"rake\", \"test\", \"--verbose\"]\n }\n\n Command overrides the image entrypoint in the exec form, as documented in\n Docker: https://docs.docker.com/engine/reference/builder/#entrypoint.\n\n3. Pass arguments to the default entrypoint:\n\n \"postCommit\": {\n\t\t \"args\": [\"rake\", \"test\", \"--verbose\"]\n\t }\n\n This form is only useful if the image entrypoint can handle arguments.\n\n4. Shell script with arguments:\n\n \"postCommit\": {\n \"script\": \"rake test $1\",\n \"args\": [\"--verbose\"]\n }\n\n This form is useful if you need to pass arguments that would otherwise be\n hard to quote properly in the shell script. In the script, $0 will be\n \"/bin/sh\" and $1, $2, etc, are the positional arguments from Args.\n\n5. Command with arguments:\n\n \"postCommit\": {\n \"command\": [\"rake\", \"test\"],\n \"args\": [\"--verbose\"]\n }\n\n This form is equivalent to appending the arguments to the Command slice.\n\nIt is invalid to provide both Script and Command simultaneously. If none of the fields are specified, the hook is not executed."

Index

Fields

fn withArgs

withArgs(args)

"args is a list of arguments that are provided to either Command, Script or the container image's default entrypoint. The arguments are placed immediately after the command to be run."

fn withArgsMixin

withArgsMixin(args)

"args is a list of arguments that are provided to either Command, Script or the container image's default entrypoint. The arguments are placed immediately after the command to be run."

Note: This function appends passed data to existing values

fn withCommand

withCommand(command)

"command is the command to run. It may not be specified with Script. This might be needed if the image doesn't have /bin/sh, or if you do not want to use a shell. In all other cases, using Script might be more convenient."

fn withCommandMixin

withCommandMixin(command)

"command is the command to run. It may not be specified with Script. This might be needed if the image doesn't have /bin/sh, or if you do not want to use a shell. In all other cases, using Script might be more convenient."

Note: This function appends passed data to existing values

fn withScript

withScript(script)

"script is a shell script to be run with /bin/sh -ic. It may not be specified with Command. Use Script when a shell script is appropriate to execute the post build hook, for example for running unit tests with rake test. If you need control over the image entrypoint, or if the image does not have /bin/sh, use Command and/or Args. The -i flag is needed to support CentOS and RHEL images that use Software Collections (SCL), in order to have the appropriate collections enabled in the shell. E.g., in the Ruby image, this is necessary to make ruby, bundle and other binaries available in the PATH."