Class BuildPostCommitSpec
- java.lang.Object
-
- io.fabric8.openshift.api.model.BuildPostCommitSpec
-
- All Implemented Interfaces:
io.fabric8.kubernetes.api.builder.Editable<BuildPostCommitSpecBuilder>,io.fabric8.kubernetes.api.model.KubernetesResource,Serializable
@Generated("io.fabric8.kubernetes.schema.generator.model.ModelGenerator") public class BuildPostCommitSpec extends Object implements io.fabric8.kubernetes.api.builder.Editable<BuildPostCommitSpecBuilder>, io.fabric8.kubernetes.api.model.KubernetesResource
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.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BuildPostCommitSpec()No args constructor for use in serializationBuildPostCommitSpec(List<String> args, List<String> command, String script)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BuildPostCommitSpecBuilderedit()Map<String,Object>getAdditionalProperties()List<String>getArgs()args is a list of arguments that are provided to either Command, Script or the container image's default entrypoint.List<String>getCommand()command is the command to run.StringgetScript()script is a shell script to be run with `/bin/sh -ic`.voidsetAdditionalProperties(Map<String,Object> additionalProperties)voidsetAdditionalProperty(String name, Object value)voidsetArgs(List<String> args)args is a list of arguments that are provided to either Command, Script or the container image's default entrypoint.voidsetCommand(List<String> command)command is the command to run.voidsetScript(String script)script is a shell script to be run with `/bin/sh -ic`.BuildPostCommitSpecBuildertoBuilder()
-
-
-
Method Detail
-
getArgs
public List<String> getArgs()
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.
-
setArgs
public void setArgs(List<String> 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.
-
getCommand
public List<String> getCommand()
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.
-
setCommand
public void setCommand(List<String> 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.
-
getScript
public String getScript()
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.
-
setScript
public void setScript(String 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.
-
edit
public BuildPostCommitSpecBuilder edit()
- Specified by:
editin interfaceio.fabric8.kubernetes.api.builder.Editable<BuildPostCommitSpecBuilder>
-
toBuilder
public BuildPostCommitSpecBuilder toBuilder()
-
-