Skip to content

CI/CD 集成

概述

为任何 CI/CD 流水线添加推送通知和审批门控。全部零依赖、开源。


命令行工具

单文件 Shell 工具。适用于任何 CI/CD、定时任务或终端。需要 curl 和 jq。

安装

curl -fsSL https://raw.githubusercontent.com/qq418716640/botbell-cli/main/botbell -o /usr/local/bin/botbell
chmod +x /usr/local/bin/botbell
export BOTBELL_TOKEN="bt_your_token"

发送

botbell send "Deploy succeeded ✅"

审批门控

botbell approve "Deploy to production?" --timeout 300

GitHub Action

为 GitHub 工作流添加 BotBell 通知和审批门控。

构建结果通知

workflow.yml
- uses: botbell/notify-action@v1
  with:
    token: ${{ secrets.BOTBELL_TOKEN }}
    title: "✅ Build Passed"
    message: "#${{ github.run_number }} on ${{ github.ref_name }}"

部署前审批门控

workflow.yml
- uses: botbell/notify-action@v1
  with:
    token: ${{ secrets.BOTBELL_TOKEN }}
    mode: approve
    message: "Deploy #${{ github.run_number }} to production?"
    timeout: "1800"

Jenkins 共享库

通过 notify 和 approve 两个方法将 BotBell 集成到 Jenkins 流水线。

配置:在全局流水线库中添加并指向 Git 仓库。

Jenkinsfile
@Library('botbell') _

pipeline {
    agent any
    environment {
        BOTBELL_TOKEN = credentials('botbell-token')
    }
    stages {
        stage('Deploy Approval') {
            steps {
                script {
                    botbell.approve(message: "Deploy to production?")
                }
            }
        }
    }
    post {
        success {
            script {
                botbell.notify(
                    title: "✅ Deploy Success",
                    message: "#${BUILD_NUMBER} deployed",
                )
            }
        }
    }
}