oc-new-build man page

oc new-build — Create a new build configuration


oc new-build [Options]


Create a new build by specifying source code

This command will try to create a build configuration for your application using images and code that has a public repository. It will lookup the images on the local Docker installation (if available), a Docker registry, or an image stream.

If you specify a source code URL, it will set up a build that takes your source code and converts it into an image that can run inside of a pod. Local source must be in a git repository that has a remote repository that the server can see.

Once the build configuration is created a new build will be automatically triggered. You can use 'oc status' to check the progress.



If true, indicates that referenced Docker images that cannot be found locally or in a registry should still be used.


If true, indicates that image stream tags that don't exist should still be used.


Instead of expecting a source URL, set the build to expect binary contents. Will disable triggers.


Specify a key-value pair to pass to Docker during the build.


Secret and destination to use as an input for the build.


Source code in the build configuration.


Context directory to be used for the build.


Name of a Docker image to use as a builder.

-D, --dockerfile=""

Specify the contents of a Dockerfile to build directly, implies --strategy=docker. Pass '-' to read from STDIN.


If true, show the result of the operation without performing it.

-e, --env=[]

Specify a key-value pair for an environment variable to set into resulting image.


File containing key-value pairs of environment variables to set into each container.


Name of an image stream to to use as a builder. (deprecated)

-i, --image-stream=[]

Name of an image stream to to use as a builder.

-l, --labels=""

Label to set in all generated resources.


Set name to use for generated build artifacts.


If true, the build output will not be pushed anywhere.

-o, --output=""

Output results as yaml or json instead of executing, or use name for succint output (resource/name).


The preferred API versions of the output objects


The name of an existing secret that should be used for pushing the output image.

-a, --show-all=true

When printing, show all resources (false means hide terminated pods.)


When printing, show all labels as the last column (default hide labels column)


If non-empty, sort list types using this field specification.  The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.


Specify an image to use as source for the build.  You must also specify --source-image-path.


Specify the file or directory to copy from the source image and its destination in the build directory. Format: [source]:[destination-dir].


The name of an existing secret that should be used for cloning a private git repository.


Specify the build strategy to use if you don't want to detect (docker|pipeline|source).


Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [ ⟨http://golang.org/pkg/text/template/#pkg-overview⟩].


Push built images to this image stream tag (or Docker image repository if --to-docker is set).


If true, have the build output push to a Docker repository.

Options Inherited from Parent Commands


Username to impersonate for the operation


Group to impersonate for the operation, this flag can be repeated to specify multiple groups.


Path to the file containing Azure container registry configuration information.


Default HTTP cache directory


Path to a cert file for the certificate authority


Path to a client certificate file for TLS


Path to a client key file for TLS


The name of the kubeconfig cluster to use


Path to the kubeconfig file to use for CLI requests.


The name of the kubeconfig context to use


The Google Cloud Platform Service Account JSON Key to use for authentication.


If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure


Maximum number of seconds between log flushes


Require server version to match client version

-n, --namespace=""

If present, the namespace scope for this CLI request


Password for basic authentication to the API server


The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests.

-s, --server=""

The address and port of the Kubernetes API server


Bearer token for authentication to the API server


The name of the kubeconfig user to use


Username for basic authentication to the API server


Print version information and quit


  # Create a build config based on the source code in the current git repository (with a public
  # remote) and a Docker image
  oc new-build . --docker-image=repo/langimage
  # Create a NodeJS build config based on the provided [image] [source code] combination
  oc new-build openshift/nodejs-010-centos7 https://github.com/openshift/nodejs-ex.git
  # Create a build config from a remote repository using its beta2 branch
  oc new-build https://github.com/openshift/ruby-hello-world#beta2
  # Create a build config using a Dockerfile specified as an argument
  oc new-build -D $'FROM centos:7\nRUN yum install -y httpd'
  # Create a build config from a remote repository and add custom environment variables
  oc new-build https://github.com/openshift/ruby-hello-world -e RACK_ENV=development
  # Create a build config from a remote private repository and specify which existing secret to use
  oc new-build https://github.com/youruser/yourgitrepo --source-secret=yoursecret
  # Create a build config from a remote repository and inject the npmrc into a build
  oc new-build https://github.com/openshift/ruby-hello-world --build-secret npmrc:.npmrc
  # Create a build config that gets its input from a remote repository and another Docker image
  oc new-build https://github.com/openshift/ruby-hello-world --source-image=openshift/jenkins-1-centos7 --source-image-path=/var/lib/jenkins:tmp

See Also



June 2016, Ported from the Kubernetes man-doc generator

Referenced By


Openshift CLI User Manuals June 2016