#!/bin/bash array=( folder1 repofolder2 another_repo_folder ) FROM=staging TO=master for i in "${array[@]}" do cd /full/path/to/repo/containing/folder/$i REPO=`git remote show origin | grep Push | grep MAIN_REPO_NAME | cut -d "/" -f 5 | cut -d "." -f 1` curl -X POST -H "Content-Type: application/json" -u USERNAME_HERE:PASSWORD_HERE https://bitbucket.org/api/2.0/repositories/BITBUCKER_OWNER_HERE/$REPO/pullrequests -d '{ "title": "'$FROM' to '$TO'", "description": "AUTO: '$FROM' to '$TO'", "source": { "branch": { "name": "'$FROM'" }, "repository": { "full_name": "BITBUCKER_OWNER_HERE/'$REPO'" } }, "destination": { "branch": { "name": "'$TO'" } }, "close_source_branch": false }' done |