Work with Builds
Using Builds
Abstract
Chapter 1. Managing Builds Copy linkLink copied to clipboard!
After installing Builds, you can create builds using buildah, source-to-image, or buildpacks. You can also use an Open Container Initiative (OCI) to create your build. You can also delete custom resources that are not required for a build.
1.1. Creating a buildah build Copy linkLink copied to clipboard!
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 installed the
ocCLI. -
Optional: You have installed the
shpCLI.
Procedure
Create a
Buildresource and apply it to the OpenShift Container Platform cluster by using one of the CLIs:Example: Using
ocCLICopy 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
dockerfilestrategy 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-exampleis the name of the current project. Ensure that the specified project exists to allow the image push.
Example: Using
shpCLIshp 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
dockerfilestrategy 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-exampleis the name of the current project. Ensure that the specified project exists to allow the image push.
Check if the
Buildresource is created by using one of the CLIs:Example: Using
ocCLIoc get builds.shipwright.io buildah-golang-build
$ oc get builds.shipwright.io buildah-golang-buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example: Using
shpCLIshp build list
$ shp build listCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
BuildRunresource and apply it to the OpenShift Container Platform cluster by using one of the CLIs:Example: Using
ocCLICopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
spec.build.namefield denotes the respective build to run, which is expected to be available in the same namespace.
Example: Using
shpCLIshp build run buildah-golang-build --follow
$ shp build run buildah-golang-build --follow1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Optional: By using the
--followflag, you can view the build logs in the output result.
Check if the
BuildRunresource is created by running one of the following commands:Example: Using
ocCLIoc get buildrun buildah-golang-buildrun
$ oc get buildrun buildah-golang-buildrunCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example: Using
shpCLIshp buildrun list
$ shp buildrun listCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
BuildRunresource creates aTaskRunresource, 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
STATUSfield asCompleted:oc get pods -w
$ oc get pods -wCopy 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 55sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
TaskRunresource shows theSUCCEEDEDfield asTrue:oc get tr
$ oc get trCopy 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 8m51sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
BuildRunresource shows theSUCCEEDEDfield asTrue:oc get br
$ oc get brCopy 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 11mCopy to Clipboard Copied! Toggle word wrap Toggle overflow During verification, if a build run fails, you can check the
status.failureDetailsfield in yourBuildRunresource to identify the exact point where the failure happened in the pod or container.NoteThe pod might switch to a
NotReadystate 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.imagefield. 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
Buildresource. For example, you can usebuildah-exampleas the project name andsample-go-appas the image name.
1.1.1. Creating buildah build in a network-restricted environment Copy linkLink copied to clipboard!
You can create a buildah build in a network-restricted environment by mirroring the images required by the buildah build strategy.
Prerequisites
- Your cluster can connect and interact with the git source that you can use to create the buildah build.
Procedure
Run the following command to mirror the images required by the
buildahbuild strategy:oc image mirror --insecure -a <registry_authentication> registry.redhat.io/ubi8/buildah@sha256:1c89cc3cab0ac0fc7387c1fe5e63443468219aab6fd531c8dad6d22fd999819e <mirror_registry>/<repo>/ubi8_buildah
$ oc image mirror --insecure -a <registry_authentication> registry.redhat.io/ubi8/buildah@sha256:1c89cc3cab0ac0fc7387c1fe5e63443468219aab6fd531c8dad6d22fd999819e <mirror_registry>/<repo>/ubi8_buildahCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Perform the steps mentioned in the "Creating a buildah build" section.
1.2. Creating a source-to-image build Copy linkLink copied to clipboard!
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 installed the
ocCLI. -
Optional: You have installed the
shpCLI.
Procedure
Create a
Buildresource and apply it to the OpenShift Container Platform cluster by using one of the CLIs:Example: Using
ocCLICopy 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-imagestrategy 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
repowith 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-registryfor authentication, see "Authentication to container registries".
Example: Using
shpCLICopy 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-imagestrategy 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
repowith 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-registryfor authentication, see "Authentication to container registries".
Check if the
Buildresource is created by using one of the CLIs:Example: Using
ocCLIoc get builds.shipwright.io s2i-nodejs-build
$ oc get builds.shipwright.io s2i-nodejs-buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example: Using
shpCLIshp build list
$ shp build listCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
BuildRunresource and apply it to the OpenShift Container Platform cluster by using one of the CLIs:Example: Using
ocCLICopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
spec.build.namefield denotes the respective build to run, which is expected to be available in the same namespace.
Example: Using
shpCLIshp build run s2i-nodejs-build --follow
$ shp build run s2i-nodejs-build --follow1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Optional: By using the
--followflag, you can view the build logs in the output result.
Check if the
BuildRunresource is created by running one of the following commands:Example: Using
ocCLIoc get buildrun s2i-nodejs-buildrun
$ oc get buildrun s2i-nodejs-buildrunCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example: Using
shpCLIshp buildrun list
$ shp buildrun listCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
BuildRunresource creates aTaskRunresource, 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
STATUSfield asCompleted:oc get pods -w
$ oc get pods -wCopy 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 2mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
TaskRunresource shows theSUCCEEDEDfield asTrue:oc get tr
$ oc get trCopy 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 13sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check whether the respective
BuildRunresource shows theSUCCEEDEDfield asTrue:oc get br
$ oc get brCopy 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 15sCopy to Clipboard Copied! Toggle word wrap Toggle overflow During verification, if a build run fails, you can check the
status.failureDetailsfield in yourBuildRunresource to identify the exact point where the failure happened in the pod or container.NoteThe pod might switch to a
NotReadystate 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.imagefield. 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
Buildresource. For example, you can uses2i-nodejs-exampleas the image name.
1.2.1. Creating source-to-image build in a network-restricted environment Copy linkLink copied to clipboard!
You can create a source-to-image build in a network-restricted environment by mirroring the images required by the source-to-image build strategy.
Prerequisites
- Your cluster can connect and interact with the git source that you can use to create the source-to-image build.
-
You have the builder-image required to create the
source-to-imagebuild in your local registry. If you do not have the builder-image in the local registry, mirror the source image.
Procedure
Run the following command to mirror the images required by the
source-to-imagebuild strategy:oc image mirror --insecure -a <registry_authentication> registry.redhat.io/source-to-image/source-to-image-rhel8@sha256:d041c1bbe503d152d0759598f79802e257816d674b342670ef61c6f9e6d401c5 <mirror_registry>/<repo>/source-to-image-source-to-image-rhel8
$ oc image mirror --insecure -a <registry_authentication> registry.redhat.io/source-to-image/source-to-image-rhel8@sha256:d041c1bbe503d152d0759598f79802e257816d674b342670ef61c6f9e6d401c5 <mirror_registry>/<repo>/source-to-image-source-to-image-rhel8Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Perform the steps mentioned in the "Creating a source-to-image build" section.
1.3. Creating a buildpacks build Copy linkLink copied to clipboard!
You can create a buildpacks build and push the created image to the target registry. The following types of buildpacks cluster build strategy are available for builds for Red Hat OpenShift:
-
buildpacksstrategy -
buildpacks-extenderstrategy
The buildpacks-extender strategy is compatible with the experimental buildpacks extender lifecycle phase. You can use this strategy for Builds on Node.js and Python. For Builds on Quarkus and Golang, use the buildpacks strategy.
Prerequisites
- You have installed the Builds for Red Hat OpenShift Operator on the OpenShift Container Platform cluster.
-
You have installed the
ocCLI. -
You have created the project where your final application image is stored by using the command
oc new-project buildpacks-example. -
Optional: You have installed the
shpCLI.
Using shp CLI with buildpacks requires additional permissions setup that you must complete before you start creating a buildpacks build.
Procedure
Optional: To use the
shpCLI with buildpacks, you must first grant permission to thepipelineservice account to access the image registry in thebuildpacks-exampleproject with the following two commands:oc policy add-role-to-user system:image-puller system:serviceaccount:default:pipeline --namespace=buildpacks-example
$ oc policy add-role-to-user system:image-puller system:serviceaccount:default:pipeline --namespace=buildpacks-exampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc policy add-role-to-user system:image-pusher system:serviceaccount:default:pipeline --namespace=buildpacks-example
$ oc policy add-role-to-user system:image-pusher system:serviceaccount:default:pipeline --namespace=buildpacks-exampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Continue with
shpCLI by switching back to the primary working project:oc project default
$ oc project defaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Finish
shpCLI setup by applying the permission:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
Buildresource and apply it to the OpenShift Container Platform cluster by using one of the following CLIs:Using
ocCLICopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Defines the Git repository containing your application source code.
- 2
- Defines the build strategy to build the container.
- 3
- Defines the parameters set for the buildpacks strategy.
- 4
- Specifies the base image on which your application runs.
- 5
- Specifies the builder image used by Cloud Native Buildpacks (CNB) to detect and build your application.
- 6
- Specifies the subdirectory within your Git repository where the application source code is located.
- 7
- Specifies the location where the built image is pushed.
Using
shpCLI:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Check if the
Buildresource was created by using one of the following CLIs:Using
ocCLI:oc get builds.shipwright.io buildpack-nodejs-build
$ oc get builds.shipwright.io buildpack-nodejs-buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow Using
shpCLI:shp build list
$ shp build listCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create a
BuildRunresource and apply it to the OpenShift Container Platform cluster by using one of the following CLIs:Using
ocCLI:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specifies the
buildpack-nodejs-buildresource that will be executed.
Using
shpCLI:…
shp build run buildpack-nodejs-buildrun --follow
$ shp build run buildpack-nodejs-buildrun --follow
+
The shp CLI version 0.16.0 cannot automatically generate a name for the BuildRun resource. You must create the name manually:
Create a
BuildRunresource with a unique name.shp buildrun create buildpack-nodejs-<buildrun_resource_name> --buildref-name buildpack-nodejs-build
$ shp buildrun create buildpack-nodejs-<buildrun_resource_name> --buildref-name buildpack-nodejs-build1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specifies the flag referencing the build.
Follow the logs:
shp buildrun logs buildpack-nodej-<buildrun_resource_name> --follow
$ shp buildrun logs buildpack-nodej-<buildrun_resource_name> --followCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Check if the
BuildRunresource was created by using one of the following CLIs:Using
ocCLI:oc get buildrun buildpack-nodejs-buildrun
$ oc get buildrun buildpack-nodejs-buildrunCopy to Clipboard Copied! Toggle word wrap Toggle overflow Using
shpCLI:shp buildrun list
$ shp buildrun listCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe
BuildRunresource creates aTaskRunresource, which then creates the pods to execute build strategy steps.
Verification
- Wait for all containers to complete their tasks.
Check if the pod shows the
STATUSfield asCompleted:oc get pods -w
$ oc get pods -wCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE buildpack-go-build-ttwkl-d8x97-pod 2/8 NotReady 0 63s buildpack-go-build-ttwkl-d8x97-pod 0/8 Completed 0 72s buildpack-go-build-ttwkl-d8x97-pod 0/8 Completed 0 73s
NAME READY STATUS RESTARTS AGE buildpack-go-build-ttwkl-d8x97-pod 2/8 NotReady 0 63s buildpack-go-build-ttwkl-d8x97-pod 0/8 Completed 0 72s buildpack-go-build-ttwkl-d8x97-pod 0/8 Completed 0 73sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check if the
TaskRunresource shows theSUCCESSfield asTrue:oc get tr
$ oc get trCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildpack-go-build-ttwkl-d8x97 True Succeeded 112s 38s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildpack-go-build-ttwkl-d8x97 True Succeeded 112s 38sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check if the
BuildRunresource shows theSUCCESSfield asTrue:oc get br
$ oc get brCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildpack-go-build-ttwkl True Succeeded 107s 33s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME buildpack-go-build-ttwkl True Succeeded 107s 33sCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf the build run fails, you can check the
status.failureDetailsfield in yourBuildRunresource to identify the exact point where the failure happened in the pod or container.The pod might switch to a
NotReadystate because one of the containers has completed its task. This is an expected behavior.Check if the image has been pushed to the registry you specified in the
build.spec.output.imagefield by running the following command from a node that can access the internal registry to pull the image:podman pull
$ podman pullCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
image-registry.openshift-image-registry.svc:5000/buildpacks-example/taxi-app
$ image-registry.openshift-image-registry.svc:5000/buildpacks-example/taxi-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow The project name in this example is
buildpacks-example, and the image name istaxi-app.
1.4. Creating a build with OCI artifacts Copy linkLink copied to clipboard!
You can create a build using an Open Container Initiative(OCI) artifact as your source code. An OCI artifact, also known as a scratch image, contains only the source code and is not intended to run as a container. You can pull the OCI artifact from a container registry and extract its contents to use as source code to run the build.
Prerequisites
- You have installed the Builds for Red Hat OpenShift Operator on the OpenShift Container Platform cluster.
-
You have installed the
occommand-line interface (CLI). -
You have installed the
shpCLI.
Procedure
Create a
Buildresource and apply it to the OpenShift Container Platform cluster. See the following example configuration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Defines the name of the
Buildresource. - 2
- Replace
<quay.io/org/image:tag>with the location of the OCI artifact source image. - 3
- Replace
<strategy-name>with the name of the build strategy to build the container (buildahorsource-to-image). - 4
- Replace
<target-image-registry/repository/image:tag>with the location where you want to push the built image. - 5
- Optional: Replace
<secret-name-for-credentials>with the secret name that stores the credentials for pushing container images. To generate a secret for a private registry for authentication, see Authentication to container registries
Choose one of the following methods to upload your source code to the required registry and run the build:
Use the
shpCLI:Run the following command in the directory containing the local source code. It packages your source code into a scratch container image, pushes it to the required registry, and runs the build:
shp build upload my-oci-build
$ shp build upload my-oci-build1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Defines the name of the
Buildresource.
Upload the OCI artifact manually:
Create a
Containerfilein the root directory of your source code and add the following configuration:FROM scratch COPY . /
FROM scratch COPY . /Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command in the root directory of your source code to build the container image using Podman:
podman build -t <registry-path>/<image-name>:<tag>
$ podman build -t <registry-path>/<image-name>:<tag>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <registry-path>/<image-name>:<tag> with the build location for the container image.
Push the container image to the required location using the following command:
podman push <registry-path>/<image-name>:<tag>
$ podman push <registry-path>/<image-name>:<tag>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <registry-path>/<image-name>:<tag> with the location where you want to push the built image.
Run the build using the following command:
shp build run my-oci-build
$ shp build run my-oci-build1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Defines the name of the
Buildresource.
1.5. Editing the resources Copy linkLink copied to clipboard!
You can edit the resources that are created by buildah, source-to-image and buildpacks build processes using the oc CLI. You can modify the resources as needed in your project.
Prerequisites
-
You have installed the
ocCLI.
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,buildrunorbuildstrategy) 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.6. Deleting the resources Copy linkLink copied to clipboard!
You can delete resources created by the Buildah, Source-to-Image (S2I), and Buildpacks 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.6.1. Deleting a build resource Copy linkLink copied to clipboard!
You can delete a build resource if it is not required in your project.
Prerequisites
-
You have installed the
ocCLI. - Optional: You have installed the shp CLI.
Procedure
Delete a
buildresource by using one of the following CLIs:Using
ocCLIoc 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
buildresource.
Using
shpCLIshp 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
buildresource.
1.6.2. Deleting a buildrun resource Copy linkLink copied to clipboard!
You can delete a buildrun resource if it is not required in your project.
Prerequisites
-
You have installed the
ocCLI. - Optional: You have installed the shp CLI.
Procedure
Delete a
buildresource by using one of the following CLIs:Using
ocCLIoc 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
buildrunresource.
Using
shpCLIoc 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
buildrunresource.
1.6.3. Deleting a buildstrategy resource Copy linkLink copied to clipboard!
You can delete a buildstrategy resource if it is not required in your project.
Prerequisites
-
You have installed the
ocCLI.
Procedure
Delete a
buildstrategyresource by using theocCLI: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
buildstrategyresource.
Legal Notice
Copy linkLink copied to clipboard!
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.