【问题标题】:Openshift webhook branch filterOpenshift webhook 分支过滤器
【发布时间】:2016-04-22 09:01:43
【问题描述】:

我成功安装了 Openshift Origin(最新),并执行了自动构建。

也就是说,一旦我在 master 分支上推送了一些内容,我就会使用 Openshift 触发器提供的 URL 通过 git webhook 触发构建。

现在我想仅在更新特定分支时触发构建。

我创建了一个新的dev 分支,并添加了一个带有其专用服务和路由的新版本。

但是当我推入master 时,dev 构建也会被触发。当我推入 dev 时,master 也会发生同样的情况,尽管我使用正确的分支名称更新了 Source ref:。

但是,master 构建使用master 分支,而dev 构建使用dev 分支完成。但我只希望在我推入 dev 分支时触发 dev 构建。

这是以下命令的 YAML 输出:oc get buildconfigs lol-master --output=yaml

apiVersion: v1
kind: BuildConfig
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftWebConsole
  creationTimestamp: 2016-04-22T06:02:16Z
  labels:
    app: lol-master
  name: lol-master
  namespace: lol
  resourceVersion: "33768"
  selfLink: /oapi/v1/namespaces/lol/buildconfigs/lol-master
  uid: c3d383c3-084f-11e6-978b-525400659b2e
spec:
  output:
    to:
      kind: ImageStreamTag
      name: lol-master:latest
      namespace: lol
  postCommit: {}
  resources: {}
  source:
    git:
      ref: master
      uri: http://git-ooo-labs.apps.10.2.2.2.xip.io/ooo/lol.git
    secrets: null
    type: Git
  strategy:
    sourceStrategy:
      from:
        kind: ImageStreamTag
        name: ruby:latest
        namespace: openshift
    type: Source
  triggers:
  - github:
      secret: cd02b3ebed15bc98
    type: GitHub
  - generic:
      secret: 7be2f555e9d8a809
    type: Generic
  - type: ConfigChange
  - imageChange:
      lastTriggeredImageID: centos/ruby22-centos7@sha256:990326b8ad8c4ae2619b24d019b7871bb10ab08c41e9d5b19d0b72cb0200e28c
    type: ImageChange
status:
  lastVersion: 18

我错过了什么吗?

非常感谢

【问题讨论】:

  • 你能指出我可以学习的方向吗"add a new build with its dedicated service and route" - 我也想创建一个 OpenShift 应用程序的“开发版本”,但不知道如何开始。我以为我只需要在 OpenShift 中为开发人员创建另一个项目(也许“克隆”生产应用程序?),在 GitHub 中创建一个 "development" 分支,然后修改新项目的构建配置以使用 "development" 分支?

标签: git git-branch webhooks openshift-origin


【解决方案1】:

您在 BuildConfig 中指向 master 分支:

 source:
    git:
      ref: master
      uri: http://git-ooo-labs.apps.10.2.2.2.xip.io/ooo/lol.git
    secrets: null
    type: Git

但应该指向dev,正如你所说的。通常,master 和 dev 分支需要单独的 BC,并且每个分支都会相应地配置 webhook。此外,分支的格式为 refs/heads/dev,因为这是 OpenShift 从 github 获取的信息。

在code 中,我们正在检查匹配的分支,如果不匹配则忽略钩子。请再次检查,如果您仍然遇到问题,我会要求您针对 https://github.com/openshift/origin 打开一个错误并提供详细说明。

【讨论】:

  • 感谢您的评论。我尝试使用格式ref/heads/dev,但在日志Error: build error: error: pathspec 'refs/heads/dev' did not match any file(s) known to git. 中出现以下错误。顺便说一句,构建也在 prod 和 master env 上运行。我会尝试在 GitHub 上打开一个错误请求。
【解决方案2】:

我在 Github 上创建了一个与此行为相关的问题 (GitHub issue #8600)。有人说我需要使用 Github webhook,而不是在这种情况下使用通用 webhook。

我将 webhook 切换为 github 类型,它就像一个魅力。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-17
    • 1970-01-01
    • 2020-01-17
    • 2018-12-19
    • 1970-01-01
    • 1970-01-01
    • 2018-01-19
    • 1970-01-01
    相关资源
    最近更新 更多