Branch not building

A useful script to manually trigger builds on arbitrary projects / branches as a workaround:

#!/bin/bash -e

# Usage:
# 
#   1. set $CIRCLE_API_TOKEN
#   2. run `./trigger-build <account> <oroject> [<branch>]`
#
#   For https://github.com/iambob/myfirstproject:
#
#       trigger_build iambob myfirstproject
#
#   ... will build master
_account=$1 # e.g. github user name or organization name
_project=$2  # e.g. my_repo_name
_branch=${3:-"master"}   #optional, defaults to master.

_circle_token=${CIRCLE_API_TOKEN}



echo "Triggering build of $_project ($_branch)."
trigger_build_url="https://circleci.com/api/v1.1/project/github/${_account}/${_project}/build?circle-token=${_circle_token}"
post_data="{ \"branch\": \"${_branch}\"}"

curl -s \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data "${post_data}" \
-request POST "${trigger_build_url}"
2 Likes