如何禁用Openshift中由构建配置触发的自动构建?

时间:2019-04-16 10:53:06

标签: openshift openshift-origin openshift-3

我正在尝试使用openshift创建cicd管道。最初,当使用“ oc new-app”命令创建应用程序时,它将自动触发构建。除了删除或取消构建外,我还需要如何禁用初始构建?

1 个答案:

答案 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>,构建才会运行。

我希望这个用例对您有所帮助。