聊天驱动式持续集成:微软Teams + Atlassian Bamboo

本文介绍了一种使用微软Teams聊天消息触发Atlassian Bamboo持续集成任务的方法。通过无服务器架构,用户可以在Teams中执行Bamboo命令,接收任务结果和监控。此外,还详细说明了设置过程和可用的命令选项。

Bamboo-on-Teams

一个无服务器架构,聊天驱动的运维工具。可以在微软Teams里通过发送聊天消息来触发Atlassian Bamboo任务,并且在Teams里接受对应的结果推送。

功能

  • Bamboo交互 - 通过使用内置的 命令 来和Bamboo进行交互
    builddeploy

  • 消息推送 - 任务运行结果会被推送到配置的Teams频道
    build-notification
    deploy-notification

  • 任务监控 - 监控Bamboo任务执行,并对超时任务推送警告到配置的Teams频道
    hanging-detect

项目链接

https://github.com/GaaraZhu/bamboo-on-teams

工作原理

Bamboo交互

用户通过Teams内置的outgoing webhook以及bamboo-on-teams服务,来和Bamboo进行交互.
序列图

消息推送和任务监控

Bamboo-on-teams内置的stepfunction会从Bamboo服务器抓取任务的最新状态,通过Teams的incoming webhook推送到配置好的频道.序列图

设置

  1. Teams里创建 incoming webhook 来接受消息,并将生成的URL拷贝出来,设置成notificationURL AWS parameter的值.
  2. Teams里创建 outgoing webhook 来指向Bamboo-on-Teams服务URL, 并且拷贝生成的HMAC token, 设置成teamsHMACSharedToken AWS parameter的值.
  3. Bamboo里创建 个人访问token 给bamboo-on-teams service使用, 拷贝出来,设置成bambooAPIToken AWS parameter的值.
  4. 在AWS parameter store里添加下面的parameters
## Infrastructure configuration ##
# ID of the AWS account in which the stack is going to be created
/bamboo-on-teams/accountId

# Custom deployment bucket
/bamboo-on-teams/deploymentBucket

# VPC configuration to access the private bamboo REST API(Optional if Bamboo Rest API is public available)
/bamboo-on-teams/securityGroupId
/bamboo-on-teams/subnetId

## Application configuration ##
/bamboo-on-teams/applicationConfig

系统配置样例:

{
    "bambooHostUrl": "test.co.nz",
    "bambooAPIToken": "NjsDAFDHkoVOASXIM4QDSDFSgRQ",
    "hmacToken": "neasdffz+LPsYZGsdddxyOvWSiK8=",
    "notificationURL": "https://test.webhook.office.com/webhookb2/85dcasdfaf@864e4889-04a2-416e-9f88-ca5ce1c6c1b7/IncomingWebhook/9db3asdfaa369/be873347-c615-4984-ad7a-f7952283551e",
    "enabledForProd": false,
}
  1. 通过package.json里定义的脚本进行编译和部署Bamboo-on-Teams服务。
  2. 在Teams频道里, @ 新创建的outgoing webhook,开始执行命令.

语法

<command> [options]

Use " help" for information on a specific command. The synopsis for each command shows its options and their usage.

可用的命令

Build命令

  • list-plans
  • search-plans
  • list-branches
  • list-builds
  • desc-build
  • create-branch
  • build

部署命令

  • list-projects
  • search-projects
  • list-envs
  • list-releases
  • list-deploys
  • create-release
  • deploy-latest
  • deploy-release
  • deploy-build
  • promote-release

其他命令

  • help

命令使用

list-plans

Usage: list-plans
List bamboo plans.

search-plans

Usage: search-plans [options]
Search build plans.
Options:
  -s, --service <service>  wildcard service name, e.g. customers
  -h, --help               display help for command

list-branches

Usage: list-branches [options]
List branch plans for a service.
Options:
  -s, --service <service>  service name, e.g. customers-v1
  -h, --help               display help for command

list-builds

Usage: list-builds [options]
List builds for a service in a branch plan.
Options:
  -s, --service <service>  service name, e.g. customers-v1
  -b, --branch <branch>    bamboo branch name, e.g. release-1.0.0
  -h, --help               display help for command

desc-build

Usage: desc-build [options]
Describe a build.
Options:
  -b, --build <build>  build key, e.g. API-CCV28-1
  -h, --help           display help for command

create-branch

Usage: create-branch [options
Create branch for a plan.
Options:
  -s, --service <service>       service name, e.g. customers-v1
  -b, --vcs-branch <vcsBranch>  vcsBranch name, e.g. master
  -h, --help                    display help for command

build

Usage: build [options]
Trigger a branch build for a service.
Options:
  -s, --service <service>  service name, e.g. customers-v1
  -b, --branch <branch>    bamboo branch name, e.g. master
  -h, --help               display help for command

list-projects

Usage: list-projects
List deployment projects.

search-projects

Usage: search-projects [options]
Search deployment projects.
Options:
  -s, --service <service>  wildcard service name, e.g. customers
  -h, --help               display help for command

list-envs

Usage: list-envs [options]
List available environments for a service.
Options:
  -s, --service <service>  service name, e.g. customers-v1
  -h, --help               display help for command

list-releases

Usage: list-releases [options]
List the releases created from a service branch.
Options:
  -s, --service <service>  service name, e.g. customers-v1
  -b, --branch <branch>    bamboo branch name, e.g. master
  -h, --help               display help for command

list-deploys

Usage: list-deploys [options]
List the deployments in a service environment.
Options:
  -s, --service <service>  service name, e.g. customers-v1
  -e, --env <env>          env name, e.g. dev
  -h, --help               display help for command

create-release

Usage: create-release [options]
Create a release for a service build.
Options:
  -s, --service <service>  service name, e.g. customers-v1
  -b, --build <build>      build key, e.g. API-CCV28-1
  -r, --release <release>  release name, e.g. v1.0.0
  -h, --help               display help for command

deploy-latest

Usage: deploy-latest [options]
Deploy the service with the latest build in a branch to an environment.
Options:
  -s, --service <service>  service name, e.g. customers-v1
  -b, --branch <branch>    bamboo branch name, e.g. master
  -e, --env <env>          env name, e.g. dev
  -h, --help               display help for command

deploy-release

Usage: deploy-release [options]
Deploy a release to a service environment.
Options:
  -s, --service <service>  service name, e.g. customers-v1
  -e, --env <env>          env name, e.g. dev
  -r, --release <release>  release name, e.g. v1.0.0
  -h, --help               display help for command

deploy-build

Usage: deploy-build [options]
Deploy a service build to an environment.
Options:
  -s, --service <service>     service name, e.g. customers-v1
  -e, --env <env>             env name, e.g. dev
  -b, --build-key <buildKey>  bamboo build key, e.g. API-CPV1-30
  -h, --help                  display help for command

promote-release

Usage: promote-release [options]
Promote the release from one environment to another.
Options:
  -s, --service <service>        service name, e.g. customers-v1
  -se, --source-env <sourceEnv>  source environment name, e.g. dev
  -te, --target-env <targetEnv>  target environment name, e.g. test
  -h, --help                     display help for command
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值