Bitbucket

Number of APIs: 9

Bitbucket code coverage

PPT and Demo: https://docs.google.com/presentation/d/1Fned6bpBIncRMdgIdMmA0gkoCUXRVpHw5jn78izQ1mM/edit?usp=sharing

Setup

  1. Clone the environment: [
  2. Obtain and fill the required secrets:
    a. bitbucketclientid
    b. bitbucketsecret
    c. apitemplate
    apikey
    d. slack
    bot_token

    To get bitbucket_client_id and bitbucket_secret: On your Bitbucket account go to workspace settings -> oauth consumers -> add consumers
    To get apitemplate_api_key, create an account on https://app.apitemplate.io/ and then go to API integration
    Get slack_bot_token from ayush.jain on slack.

  3. Configure other environment variables:
    a. project_id : Project id from url on bitbucket for your project.
    b. apitemplate_template_id : Reach out ayush.jain on Slack
    c. slack_channel_id : Open slack on browser and browse the channel you want to post the updates on. Copy the last part of the url after slash (last path) Eg: C03JLAD8T7C.
    d. comparision_days : Number of days to compare your current coverage from
    e. tag_user : Slack user name of the person you want to cc to report thread on slack

Run

Can be run using either of the 2 ways:

  • Create a weekly/monthly monitor to run this collection.
  • Use Qodex runner to run the collection.
  1. Pipelines - Get pipelines from previous GET https://api.bitbucket.org/2.0/repositories/:workspace/:repo_slug/pipelines/?page=1&pagelen=30&sort=-created_on&target.branch=develop

  2. Pipelines - List pipeline steps from previous GET https://api.bitbucket.org/2.0/repositories/:workspace/:repo_slug/pipelines/:pipeline_uuid/steps/

  3. Slack APIs - Add remote file POST https://slack.com/api/files.remote.add

  4. Pipelines - Get step log new GET https://api.bitbucket.org/2.0/repositories/:workspace/:repo_slug/pipelines/:pipeline_uuid/steps/:step_uuid/log

  5. Auth - Access token POST https://bitbucket.org/site/oauth2/access_token

  6. Repos - Get project repos GET https://api.bitbucket.org/2.0/repositories/:workspace?q=project.key="{{project_id}}"

  7. Apitemplate - Get coverage PDF POST https://rest.apitemplate.io/v2/create-pdf?template_id={{apitemplate_template_id}}

  8. Slack APIs - Share remote file POST https://slack.com/api/files.remote.share

  9. Slack APIs - Reply to thread POST https://slack.com/api/chat.postMessage