如何使用Jenkins Pipeline在OpenShift容器平台中检查图像速度是否存在

发布于 2025-02-09 21:16:41 字数 1158 浏览 3 评论 0原文

我运行了此代码以检查和删除OpenShift中的成像仪

 openshift.withCluster("${CLUSTER_NAME}") {
                        openshift.withProject("${DEV_ENV}") {
                            if (openshift.selector('imagestreams', '${imagestream_name}').exists()) {
                                openshift.selector('imagestreams', '${imagestream_name}').delete()

那我跑了这个

openshift.withCluster("${CLUSTER_NAME}") {
                        openshift.withProject("${DEV_ENV}") {
                            openshift.apply(openshift.raw("create -f '${imagestream_name}'.yaml"))

要从本地yaml文件创建新的成像剧院,但最终会出现此错误

ERROR: raw command [create -f 'imagestream-test'.yaml] returned an error;
{err=Error from server (AlreadyExists): error when creating "imagestream-test.yaml": imagestreams.image.openshift.io "testimagestream" already exists

无论如何,是否可以检查图像传播是否已经在OpenShift中?

I ran this code to check and delete the imagestreams in Openshift

 openshift.withCluster("${CLUSTER_NAME}") {
                        openshift.withProject("${DEV_ENV}") {
                            if (openshift.selector('imagestreams', '${imagestream_name}').exists()) {
                                openshift.selector('imagestreams', '${imagestream_name}').delete()

then I ran this

openshift.withCluster("${CLUSTER_NAME}") {
                        openshift.withProject("${DEV_ENV}") {
                            openshift.apply(openshift.raw("create -f '${imagestream_name}'.yaml"))

to create new imagestream from local yaml file but it end up with this error

ERROR: raw command [create -f 'imagestream-test'.yaml] returned an error;
{err=Error from server (AlreadyExists): error when creating "imagestream-test.yaml": imagestreams.image.openshift.io "testimagestream" already exists

Is there anyway to check if the imagestream is already in openshift ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

囚你心 2025-02-16 21:16:41

如何使用应用而不是创建OC应用如果不存在或更新,则将创建资源。

openshift.withCluster("${CLUSTER_NAME}") {
                        openshift.withProject("${DEV_ENV}") {
                            openshift.apply(openshift.raw("apply -f '${imagestream_name}'.yaml"))

How about using apply instead of create? oc apply will create a resource if it doesn't exist or update if it does.

openshift.withCluster("${CLUSTER_NAME}") {
                        openshift.withProject("${DEV_ENV}") {
                            openshift.apply(openshift.raw("apply -f '${imagestream_name}'.yaml"))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文