Code Monkey home page Code Monkey logo

bamboo-on-teams's Introduction

Bamboo-on-Teams

Serverless GitHub license Build Status

A Serverless ChatOps tool to interact with Atlassian Bamboo from Microsoft Teams.

Features

  • Bamboo interaction - interact with Bamboo in Microsoft Teams with wide range of commands, and get Teams notifications afterwards.
  • On-demand CI/CD automation - automatically build, test, and deploy with Bamboo in Microsoft Teams.
  • Hanging detection - detect hanging Bamboo jobs and alert in Microsoft Teams.

build-and-deploy build-and-deploy-result

Blogpost

Chat the Ops up

Learn by example!

Cheatsheet

Demo

Demo

How it works

User interacts with Bamboo through Teams outgoing webhook and bamboo-on-teams service, and get notifications via Teams incoming webhook. Bamboo interaction

Setup

  1. In Teams, create an incoming webhook to receive job notification and copy the URL out as the notificationURL value in application configuration.

  2. In Teams, create an outgoing webhook with name Bamboo pointing to the Bamboo-on-Teams service, then copy the HMAC token out as the hmacToken value in application configuration.

  3. In Bamboo, create a personal access token for the dedicated bamboo-on-teams bamboo account, and copy it out as the bambooAPIToken value in application configuration.

  4. In AWS, configure required parameters in parameter store

## 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 (Required if Bamboo Rest API is hosted in a private VPC)
/bamboo-on-teams/securityGroupId
/bamboo-on-teams/subnetId

## Application configuration - SecureString using the default AWS account key ##
/bamboo-on-teams/applicationConfig

Sample application configuration:

{
    "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",
    "prod": {
         "enabled": true,
         "bambooAPIToken": "asdfaf2q2k1las0F998S",
         "allowedUserIds": ["23:13asdfaPD4UQ_-MvLgDLhHg1cUED"]
    }
}
  1. Build and deploy Bamboo-on-Teams through npm scripts in package.json.

  2. In Teams channel, tag the outgoing webhook to have fun:).

Synopsis

<command> [options]

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

Available commands

Build commands

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

Deploy commands

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

Pipeline commands

  • build-and-deploy
  • batch-create-branch
  • batch-build
  • batch-deploy
  • release
  • promote-release

Other commands

  • help

Command usage

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 or vcs branch name, e.g. release/abc or release-abc
  -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 or vcs branch name, e.g. release/abc or release-abc
  -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 or vcs branch name, e.g. release/abc or release-abc
  -h, --help               display help for command

list-deploys

Usage: list-deploys [options]
List the top three 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

Usage: deploy [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 or vcs branch name, e.g. release/abc or release-abc
  -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-deploy

Usage: promote-deploy [options]
Promote the deployment 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

build-and-deploy

Usage: build-and-deploy [options]
Build service(s) from a vcs branch (will create Bamboo branch plan automatically if not exist) and deploy to an environment.
Options:
  -s, --services <services>  service names separated by comma without spaces, e.g. customers-v1,accounts-v1
  -b, --branch <branch>      bamboo or vcs branch name, e.g. release/abc or release-abc
  -e, --env <env>            env name, e.g. dev
  -h, --help                 display help for command

batch-create-branch

Usage: batch-create-branch [options]
Batch create branch plans.
Options:
  -s, --services <services>              service names separated by comma without spaces,
                                         e.g. customers-v1,accounts-v1
  -b, --b, --vcs-branch <vcsBranch>      vcsBranch name, e.g. master
  -h, --help                             display help for command

batch-build

Usage: batch-build [options]
Batch build services.
Options:
  -s, --services <services>  service names separated by comma without spaces,
                             e.g. customers-v1,accounts-v1
  -b, --branch <branch>      bamboo or vcs branch name, e.g. release/abc or release-abc
  -h, --help                 display help for command

batch-deploy

Usage: batch-deploy [options]
Batch deploy services.
Options:
  -s, --services <services>  service names separated by comma without spaces,
                             e.g. customers-v1,accounts-v1
  -b, --branch <branch>      bamboo or vcs branch name, e.g. release/abc or release-abc
  -e, --env <env>            env name, e.g. dev
  -h, --help                 display help for command

release

Usage: release [options]
Release services in sequential batches.
Options:
  -s, --services <services>  sequential service name batches separated by semi-collon and with comma to separate service names in each batch,
                             e.g. customers-v1,accounts-v1;transactions-v1
  -b, --branch <branch>      bamboo or vcs branch name, e.g. release/abc or release-abc
  -e, --env <env>            env name, e.g. dev
  -h, --help                 display help for command

promote-release

Usage: promote-release [options]
Promote the release deployments from one environment to another in sequential batches.
Options:
  -s, --services <services>      sequential service name batches separated by semi-collon and with comma to separate service names in each batch, e.g. customers-v1,accounts-v1;transactions-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

Contribution

Your contributions are always welcome!

License

This work is licensed under MIT.

bamboo-on-teams's People

Contributors

gaarazhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bamboo-on-teams's Issues

notifying of build result

When Bamboo finished a build and deploy it would be nice to receive a mention when it is complete as having channel notification on can lead to notification spam due to other people using the tool.

I did a quick proof of concept and in my testing environment and changing the notifications to adaptive cards should do the trick using code something like this:

{ type: "message", attachments: [ { contentType: "application/vnd.microsoft.card.adaptive", content: { type: "AdaptiveCard", body: [ { type: "ColumnSet", columns: [ { type: "Column", width: 0.5, items: [ { type: "Image", url: "https://static.thenounproject.com/png/2714806-200.png", size: "Medium", }, ], }, { type: "Column", width: 3, items: [ { type: "TextBlock", text: "Bamboo build and deploy job finished", wrap: true, fontType: "Default", size: "Medium", }, { type: "TextBlock", text: triggered by ${input.triggeredBy.name}, wrap: true, }, { type: "TextBlock", text: ${input.triggeredBy.name}, wrap: true, }, ], }, ], }, ], $schema: "http://adaptivecards.io/schemas/adaptive-card.json", version: "1.0", msteams: { entities: [ { type: "mention", text: ${input.triggeredBy.name}, mentioned: { id: input.triggeredBy.id, name: input.triggeredBy.name, }, }, ], }, }, }, ], }

Let me know what you think of the idea as I am happy to assist with implementation :)

Support building and deploying multiple services with one command

The current implementation supports only build/deploy one service with one command. It will be great if it supports building or deploying multiple services with one command, for example:

@bamboo build -s customers-v1,accounts-v1,emails-v1 -b master
@bamboo deploy-latest -s customers-v1,accounts-v1,emails-v1 -b master -e test
@bamboo promote-release -s customers-v1,accounts-v1,emails-v1 -b master -e test

Multi-projects support

This will include:

  • Build and deploy services from multiple projects
    - Dedicated bamboo account for each project
    - Dedicated incoming webhook to receive notifications for each project

Remove convention that build plan has the same name with deployment project

Now the deployment job requires a service name with will be used to find both deployment project and build plan, this will be problematic when those two have different names. The solution is to get the plan key from the deployment project details and use it to pull the plan builds for deployment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.