2016-04-22 39 views
0

我成功安裝了Openshift Origin(最新版),並執行了自動化構建。Openshift webhook分支過濾器

也就是說,一旦我在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/[email protected]:990326b8ad8c4ae2619b24d019b7871bb10ab08c41e9d5b19d0b72cb0200e28c 
    type: ImageChange 
status: 
    lastVersion: 18 

我缺少的東西?

非常感謝

回答

0

我在Github上創建了一個與此行爲相關的問題(GitHub issue #8600)。我曾經說過我需要使用Github webhook,而不是這種情況下的通用webhook。

我將webhooks切換到github類型,它的功能就像一個魅力。

1

你指着主分支在BuildConfig:

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

,而應指向dev,因爲你說。一般來說,您需要將單獨的BC分配給masterdev分支,並且每個分支都將相應地配置webhook。此外,該分支的格式爲refs/heads/dev,因爲這是OpenShift從github獲取的信息。

code我們正在檢查匹配的分支,並忽略掛鉤,如果它不匹配。請再檢查一次,如果您仍然遇到問題,我會要求您打開一個針對https://github.com/openshift/origin的錯誤並提供詳細說明。

+1

感謝您的評論。我嘗試使用'ref/heads/dev'格式,但在日誌中出現以下錯誤:錯誤:構建錯誤:錯誤:pathspec'refs/heads/dev'與git.'已知的任何文件都不匹配。順便說一下,build也運行在prod和master env上。我會嘗試在GitHub上打開一個bugrequest。 – Cicatrice