上次我們是用預設的 git repo 來做示範,這次我們改用自己的 git repo 來試試看吧。
%YOUR_GITHUB_USERNAME% 改成你的 GitHub username,然後從上次步驟二的 Import YAML/JSON 把這段定義匯入。如果你有注意到的話,上次匯入的內容是 json format,這次匯入的是 yaml format
apiVersion: v1
kind: BuildConfig
metadata:
  labels:
    app: nodejs-helloworld-sample
    name: nodejs-sample-build
    template: application-template-stibuild
  name: frontend
spec:
  output:
    to:
      kind: ImageStreamTag
      name: origin-nodejs-sample:latest
  postCommit: {}
  resources: {}
  runPolicy: Serial
  source:
    git:
      uri: https://github.com/%YOUR_GITHUB_USERNAME%/nodejs-ex.git
    type: Git
  strategy:
    sourceStrategy:
      from:
        kind: ImageStreamTag
        name: nodejs-010-centos7:latest
    type: Source
  triggers:
  - github:
      secret: secret101
    type: GitHub
  - generic:
      secret: secret101
    type: Generic
設定完成後,直接到任何一個作業 (Job) 的組態設定頁面 ...
看到 Jenkins 和 Github 間 webhook 的設定方式。但是只看這一段是不 work 的,還要再看文章中的這一段:
改用 基本驗證 (Basic Authentication) 方式通過 API 驗證 ...
才會打通。
完成以上動作就可以在 Github 出 event 的時候觸發 Jenkins 執行建構與佈署了。
佈署完還能做什麼呢?當然是想辦法再把佈署完的應用 搞 爛 啊!