Este contenido no está disponible en el idioma seleccionado.
Work with Builds
Using Builds
Abstract
Chapter 1. Managing Builds Copiar enlaceEnlace copiado en el portapapeles!
After installing Builds, you can create builds using buildah
or source-to-image
build strategies. You can also delete custom resources that are not required for a build.
1.1. Creating a buildah build Copiar enlaceEnlace copiado en el portapapeles!
You can create a buildah
build and push the created image to the target registry.
Prerequisites
- You have installed the Builds for Red Hat OpenShift Operator on the OpenShift Container Platform cluster.
-
You have created a
ShipwrightBuild
resource. -
You have installed the
oc
CLI. -
Optional: You have installed the
shp
CLI.
Procedure
Create a
Build
resource and apply it to the OpenShift Container Platform cluster by using one of the CLIs:Example: Using
oc
CLICopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The location where the source code is placed.
- 2
- The build strategy that you use to build the container.
- 3
- The parameter defined in the build strategy. To set the value of the
dockerfile
strategy parameter, specify the Dockerfile location required to build the output image. - 4
- The location where the built image is pushed. In this procedural example, the built image is pushed to the OpenShift Container Platform cluster internal registry.
buildah-example
is the name of the current project. Ensure that the specified project exists to allow the image push.
Example: Using
shp
CLIshp build create buildah-golang-build \ --source-url="https://github.com/redhat-openshift-builds/samples" --source-context-dir="buildah-build" \ --strategy-name="buildah" \ --dockerfile="Dockerfile" \ --output-image="image-registry.openshift-image-registry.svc:5000/buildah-example/go-app"
$ shp build create buildah-golang-build \ --source-url="https://github.com/redhat-openshift-builds/samples" --source-context-dir="buildah-build" \
1 --strategy-name="buildah" \
2 --dockerfile="Dockerfile" \
3 --output-image="image-registry.openshift-image-registry.svc:5000/buildah-example/go-app"
4 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The location where the source code is placed.
- 2
- The build strategy that you use to build the container.
- 3
- The parameter defined in the build strategy. To set the value of the
dockerfile
strategy parameter, specify the Dockerfile location required to build the output image. - 4
- The location where the built image is pushed. In this procedural example, the built image is pushed to the OpenShift Container Platform cluster internal registry.
buildah-example
is the name of the current project. Ensure that the specified project exists to allow the image push.
Check if the
Build
resource is created by using one of the CLIs:Example: Using
oc
CLIoc get builds.shipwright.io buildah-golang-build
$ oc get builds.shipwright.io buildah-golang-build
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example: Using
shp
CLIshp build list
$ shp build list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
BuildRun
resource and apply it to the OpenShift Container Platform cluster by using one of the CLIs:Example: Using
oc
CLICopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
spec.build.name
field denotes the respective build to run, which is expected to be available in the same namespace.
Example: Using
shp
CLIshp build run buildah-golang-build --follow
$ shp build run buildah-golang-build --follow
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Optional: By using the
--follow
flag, you can view the build logs in the output result.
Check if the
BuildRun
resource is created by running one of the following commands:Example: Using
oc
CLIoc get buildrun buildah-golang-buildrun
$ oc get buildrun buildah-golang-buildrun
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example: Using
shp
CLIshp buildrun list
$ shp buildrun list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
BuildRun
resource creates aTaskRun
resource, which then creates the pods to execute build strategy steps.
Verification
After all the containers complete their tasks, verify the following:
Check whether the pod shows the
STATUS
field asCompleted
:oc get pods -w
$ oc get pods -w
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE buildah-golang-buildrun-dtrg2-pod 2/2 Running 0 4s buildah-golang-buildrun-dtrg2-pod 1/2 NotReady 0 7s buildah-golang-buildrun-dtrg2-pod 0/2 Completed 0 55s
NAME READY STATUS RESTARTS AGE buildah-golang-buildrun-dtrg2-pod 2/2 Running 0 4s buildah-golang-buildrun-dtrg2-pod 1/2 NotReady 0 7s buildah-golang-buildrun-dtrg2-pod 0/2 Completed 0 55s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
TaskRun
resource shows theSUCCEEDED
field asTrue
:oc get tr
$ oc get tr
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildah-golang-buildrun-dtrg2 True Succeeded 11m 8m51s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildah-golang-buildrun-dtrg2 True Succeeded 11m 8m51s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
BuildRun
resource shows theSUCCEEDED
field asTrue
:oc get br
$ oc get br
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildah-golang-buildrun True Succeeded 13m 11m
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildah-golang-buildrun True Succeeded 13m 11m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow During verification, if a build run fails, you can check the
status.failureDetails
field in yourBuildRun
resource to identify the exact point where the failure happened in the pod or container.NoteThe pod might switch to a
NotReady
state because one of the containers has completed its task. This is an expected behavior.
Validate whether the image has been pushed to the registry that is specified in the
build.spec.output.image
field. You can try to pull the image by running the following command from a node that can access the internal registry:podman pull image-registry.openshift-image-registry.svc:5000/<project>/<image>
$ podman pull image-registry.openshift-image-registry.svc:5000/<project>/<image>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The project name and image name used when creating the
Build
resource. For example, you can usebuildah-example
as the project name andsample-go-app
as the image name.
1.2. Creating a source-to-image build Copiar enlaceEnlace copiado en el portapapeles!
You can create a source-to-image
build and push the created image to a custom Quay repository.
Prerequisites
- You have installed the Builds for Red Hat OpenShift Operator on the OpenShift Container Platform cluster.
-
You have created a
ShipwrightBuild
resource. -
You have installed the
oc
CLI. -
Optional: You have installed the
shp
CLI.
Procedure
Create a
Build
resource and apply it to the OpenShift Container Platform cluster by using one of the CLIs:Example: Using
oc
CLICopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The location where the source code is placed.
- 2
- The build strategy that you use to build the container.
- 3
- The parameter defined in the build strategy. To set the value of the
builder-image
strategy parameter, specify the builder image location required to build the output image. - 4
- The location where the built image is pushed. You can push the built image to a custom Quay.io repository. Replace
repo
with a valid Quay.io organization or your Quay user name. - 5
- The secret name that stores the credentials for pushing container images. To generate a secret of the type
docker-registry
for authentication, see "Authentication to container registries".
Example: Using
shp
CLICopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The location where the source code is placed.
- 2
- The build strategy that you use to build the container.
- 3
- The parameter defined in the build strategy. To set the value of the
builder-image
strategy parameter, specify the builder image location required to build the output image. - 4
- The location where the built image is pushed. You can push the built image to a custom Quay.io repository. Replace
repo
with a valid Quay.io organization or your Quay user name. - 5
- The secret name that stores the credentials for pushing container images. To generate a secret of the type
docker-registry
for authentication, see "Authentication to container registries".
Check if the
Build
resource is created by using one of the CLIs:Example: Using
oc
CLIoc get builds.shipwright.io s2i-nodejs-build
$ oc get builds.shipwright.io s2i-nodejs-build
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example: Using
shp
CLIshp build list
$ shp build list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
BuildRun
resource and apply it to the OpenShift Container Platform cluster by using one of the CLIs:Example: Using
oc
CLICopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
spec.build.name
field denotes the respective build to run, which is expected to be available in the same namespace.
Example: Using
shp
CLIshp build run s2i-nodejs-build --follow
$ shp build run s2i-nodejs-build --follow
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Optional: By using the
--follow
flag, you can view the build logs in the output result.
Check if the
BuildRun
resource is created by running one of the following commands:Example: Using
oc
CLIoc get buildrun s2i-nodejs-buildrun
$ oc get buildrun s2i-nodejs-buildrun
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example: Using
shp
CLIshp buildrun list
$ shp buildrun list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
BuildRun
resource creates aTaskRun
resource, which then creates the pods to execute build strategy steps.
Verification
After all the containers complete their tasks, verify the following:
Check whether the pod shows the
STATUS
field asCompleted
:oc get pods -w
$ oc get pods -w
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE s2i-nodejs-buildrun-phxxm-pod 2/2 Running 0 10s s2i-nodejs-buildrun-phxxm-pod 1/2 NotReady 0 14s s2i-nodejs-buildrun-phxxm-pod 0/2 Completed 0 2m
NAME READY STATUS RESTARTS AGE s2i-nodejs-buildrun-phxxm-pod 2/2 Running 0 10s s2i-nodejs-buildrun-phxxm-pod 1/2 NotReady 0 14s s2i-nodejs-buildrun-phxxm-pod 0/2 Completed 0 2m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
TaskRun
resource shows theSUCCEEDED
field asTrue
:oc get tr
$ oc get tr
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME s2i-nodejs-buildrun-phxxm True Succeeded 2m39s 13s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME s2i-nodejs-buildrun-phxxm True Succeeded 2m39s 13s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
BuildRun
resource shows theSUCCEEDED
field asTrue
:oc get br
$ oc get br
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME s2i-nodejs-buildrun True Succeeded 2m41s 15s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME s2i-nodejs-buildrun True Succeeded 2m41s 15s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow During verification, if a build run fails, you can check the
status.failureDetails
field in yourBuildRun
resource to identify the exact point where the failure happened in the pod or container.NoteThe pod might switch to a
NotReady
state because one of the containers has completed its task. This is an expected behavior.
Validate whether the image has been pushed to the registry that is specified in the
build.spec.output.image
field. You can try to pull the image by running the following command after logging in to the registry:podman pull quay.io/<repo>/<image>
$ podman pull quay.io/<repo>/<image>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The repository name and image name used when creating the
Build
resource. For example, you can uses2i-nodejs-example
as the image name.
1.3. Editing the resources Copiar enlaceEnlace copiado en el portapapeles!
You can edit the resources that are created by buildah
and source-to-image
build processes using the oc
CLI. You can modify the resources as needed in your project.
Prerequisites
-
You have installed the
oc
CLI.
Procedure
Run the following command to open the YAML definition in the default editor:
oc edit <resource_name> <build_resource_name>
$ oc edit <resource_name> <build_resource_name>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<resource_name>
with the name of the resource (build
,buildrun
orbuildstrategy
) and<build_resource_name>
with the name of the build resource that you want to edit.
- Edit the YAML definition and save the file.
1.4. Deleting the resources Copiar enlaceEnlace copiado en el portapapeles!
You can delete resources created by the Buildah
and Source-to-Image
(S2I) build processes using the oc CLI or the shp CLI. Deleting these resources helps you to clean up build configurations that are no longer required in your project.
1.4.1. Deleting a build resource Copiar enlaceEnlace copiado en el portapapeles!
You can delete a build
resource if it is not required in your project.
Prerequisites
-
You have installed the
oc
CLI. - Optional: You have installed the shp CLI.
Procedure
Delete a
build
resource by using one of the following CLIs:Using
oc
CLIoc delete builds <build_resource_name>
$ oc delete builds <build_resource_name>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <build_resource_name> with the name of the
build
resource.
Using
shp
CLIshp build delete <build_resource_name>
$ shp build delete <build_resource_name>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <build_resource_name> with the name of the
build
resource.
1.4.2. Deleting a buildrun resource Copiar enlaceEnlace copiado en el portapapeles!
You can delete a buildrun
resource if it is not required in your project.
Prerequisites
-
You have installed the
oc
CLI. - Optional: You have installed the shp CLI.
Procedure
Delete a
build
resource by using one of the following CLIs:Using
oc
CLIoc delete buildrun <buildrun_resource_name>
$ oc delete buildrun <buildrun_resource_name>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <buildrun_resource_name> with the name of the
buildrun
resource.
Using
shp
CLIoc delete buildrun <buildrun_resource_name>
$ oc delete buildrun <buildrun_resource_name>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <buildrun_resource_name> with the name of the
buildrun
resource.
1.4.3. Deleting a buildstrategy resource Copiar enlaceEnlace copiado en el portapapeles!
You can delete a buildstrategy
resource if it is not required in your project.
Prerequisites
-
You have installed the
oc
CLI.
Procedure
Delete a
buildstrategy
resource by using theoc
CLI:oc delete buildstrategy <buildstartegy_resource_name>
$ oc delete buildstrategy <buildstartegy_resource_name>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <buildstartegy_resource_name> with the name of the
buildstrategy
resource.
Legal Notice
Copiar enlaceEnlace copiado en el portapapeles!
Copyright © 2025 Red Hat
OpenShift documentation is licensed under the Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0).
Modified versions must remove all Red Hat trademarks.
Portions adapted from https://github.com/kubernetes-incubator/service-catalog/ with modifications by Red Hat.
Red Hat, Red Hat Enterprise Linux, the Red Hat logo, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation’s permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.