iT邦幫忙

2021 iThome 鐵人賽

DAY 26
0

組合技 Drone + godog + Mattermost

當有需求要在k8s上透過drone定期跑godog進行BDD測試,並將測試結果推送到mattermost時,怎麼辦呢?

首先需求拆解:

Create Your Pipeline

在BDD專案內,製作你的pipeline
以下以Drone為範例

kind: pipeline
type: kubernetes
name: bdd

steps:
- name: godog solo basic.feature
  image: rain123473/godog:v0.11.0
  commands:
    - cd solo
    - godog run features/basic.feature

- name: send notification
  when:
    status:
    - success
  image: plugins/slack
  settings:
    webhook:
      from_secret: bdd
    channel: ithome-bdd
    username: drone
    icon_url: https://img.icons8.com/color/2x/good-pincode.png
    template: >
        [DEV] BDD test build {{build.link}} succeeded. Good job.

- name: send failure notification
  when:
    status:
    - failure
  image: plugins/slack
  settings:
    webhook:
      from_secret: bdd
    channel: ithome-bdd
    username: drone
    icon_url: https://img.icons8.com/color/2x/high-priority.png
    template: >
       {{#success build.status}}
        [DEV] BDD test build {{build.link}} succeeded. Good job.
       {{else}}
        [DEV] BDD build {{build.link}} failed. Fix me please.
       {{/success}}

在drone yaml設定,可以使用

  when:
    status:

來綁定此step的狀態,所以可以從step

  • send notification -> 當bdd測試「成功」寄送通知
  • send failure notification -> 當bdd測試「失敗」寄送通知

看得出來唷!


Drone Cron

再次提醒一下
Cron Jobs 的時區是依照 UTC(Universal Time Coordinated),所以需要自己在轉換一下時間
若你的需求是要台灣時間22:00~04:00,每小時觸發的話,不能打22-04唷!要改成14-20才正確!

drone cron add "my/bdd-repo" "bdd-nighty-test" "0 0 14-20 * * *" --branch master

之後就能在Mattermost該channel內看到效果囉
https://ithelp.ithome.com.tw/upload/images/20210929/20115289sCtqcVTOzj.png---


以上就完成上述之需求(在k8s上透過drone定期跑godog進行BDD測試,並將測試結果推送到mattermost)了,今天就這樣子拉~/images/emoticon/emoticon11.gif


上一篇
[Day 25] BDD - godog image封裝
下一篇
[Day 27] Gitea - 你的Gitea慢了嗎?卡卡的?
系列文
Dev's Ops 啟程30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言