我正在尝试使用openshift创建cicd管道。最初,当使用“ oc new-app”命令创建应用程序时,它将自动触发构建。除了删除或取消构建外,我还需要如何禁用初始构建?
答案 0 :(得分:0)
除了删除或取消构建外,我如何需要禁用初始构建?
def compare(a, b):
#check: both nodes empty => same trees
if(a == None and b == None):
return True
#check: only one note empty: different trees
elif((a == None and b != None) or (a != None and b == None)):
return False
#check: node content is the same and all children are the same: same tree
else:
return (a.val == b.val) and (compare(a.left, b.left) and compare(a.right, b.right))
tmp_node1 = TreeNode("tmp")
tmp_node2 = TreeNode("tmp")
a = TreeNode("something", left=tmp_node1)
b = TreeNode("something", left=tmp_node2)
c = TreeNode("somthing else")
print(compare(a,b))
print(compare(a,c))
无法阻止初始构建。
它在这里讨论过:https://github.com/openshift/origin/issues/15429
不幸的是,它现在尚未实现。
但是,您可以通过手动修改oc new-app
的Yaml来阻止从buildConfig
删除所有触发器的初始构建。
buildConfig
导出为Yaml格式。oc new-app
# oc new-app --name=test \
centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git -o yaml --dry-run > test.yml
时删除所有触发器。triggers: []
修改后,使用strategy:
sourceStrategy:
from:
kind: ImageStreamTag
name: ruby-25-centos7:latest
type: Source
triggers: []
创建资源。
oc create -f
直到运行# oc create -f test.yml
imagestream.image.openshift.io/ruby-25-centos7 created
imagestream.image.openshift.io/ruby-ex created
buildconfig.build.openshift.io/ruby-ex created
deploymentconfig.apps.openshift.io/ruby-ex created
service/ruby-ex created
和oc start-build <bc name>
,构建才会运行。
我希望这个用例对您有所帮助。