Created
May 22, 2019 18:42
-
-
Save arigesher/ec23192b95fffa7c819988b42a4ad5bd to your computer and use it in GitHub Desktop.
CircleCI manual trigger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment