Git Product home page Git Product logo

bb_cli_client's Introduction

BB CLI Client

This project enables you to connect to Bitbucket using a CLI and retreiving various information as well as doing some actions like, approving pull requests. It's configurable using a YAML configuration file config.yml and has been created to work in a Jenkins job and allow the job to retrieve information about a single pull request and do something with it, like testing or packaging.

Example configuration

See config.yml.example.

Usage

bb.py (pr|pull_request) next
bb.py (pr|pull_request) info <pr_id>
bb.py (pr|pull_request) approve <pr_id>
bb.py (pr|pull_request) unapprove (updated|all|<pr_id>)
bb.py (pr|pull_request) comment add <pr_id> <comment>
bb.py commit set tested <hash>
bb.py commit set build_status <username> <repo> <revision> <state> <job_url> <build_key>

Installation

Dependecies

pip3 install -r requirements.txt

Jenkins Job

The following script is a working example and may be used inside a Jenkins job to retrieve the "next" pull request, do some actions on that pull request (packaging, testing, etc) and store the information that it has been progressed, so that it won't retreive this pull request unless the revision at HEAD of this pull request has been changed.

#!/bin/bash

set -ex

SCRIPT="/srv/bb_cli_client/bb.py"

# If the PR has been approved and the latest commit hash is not in the list of already checked
# hashes, unapprove this PR
python3 $SCRIPT pr unapprove updated

# Get next PR data
result=($(python3 $SCRIPT pr next))

username="${result[0]}"
repo="${result[1]}"
fork="${result[2]}"
revision="${result[3]}"
branch="${result[4]}"
pr_id="${result[5]}"

# Start the test
test_result=0

if [ "$test_result" -eq "0" ]; then
  python3 $SCRIPT pr approve $pr_id
  python3 $SCRIPT pr comment add $pr_id "Testing revision ${revision} has succeeded."
else
  python3 $SCRIPT pr comment add $pr_id "Testing revision ${revision} has failed. Build ID is #${BUILD_NUMBER}"
fi

# Mark the specified revision as being "tested"
python3 $SCRIPT commit set tested $revision

TODO

  • The script should return those pull requests which are WIP if all others have been tested. This is already implemented and may be used by using the append_last setting.

bb_cli_client's People

Stargazers

Joe Constant avatar Tomás Dowling avatar

Watchers

James Cloos avatar Sebastian Wagner avatar Sebastian Krah avatar Ricardo Marques avatar

Forkers

p-se

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.