diff --git a/gitrise.sh b/gitrise.sh index b5618a8..ae7967d 100755 --- a/gitrise.sh +++ b/gitrise.sh @@ -20,19 +20,26 @@ function usage() { echo "" echo "Usage: gitrise.sh [-d] [-e] [-h] [-T] [-v] -a token -s project_slug -w workflow [-b branch|-t tag|-c commit]" echo - echo " -a, --access-token Bitrise access token" - echo " -b, --branch Git branch" - echo " -c, --commit Git commit hash " - echo " -d, --debug Debug mode enabled" - echo " -e, --env List of environment variables in the form of key1:value1,key2:value2" - echo " -h, --help Print this help text" - echo " -p, --poll Polling interval (in seconds) to get the build status." - echo " --stream Stream build logs" - echo " -s, --slug Bitrise project slug" - echo " -T, --test Test mode enabled" - echo " -t, --tag Git tag" - echo " -v, --version App version" - echo " -w, --workflow Bitrise workflow" + echo " -a, --access-token Bitrise access token" + echo " -b, --branch Git branch" + echo " -bd, --branch-dest Git destination branch" + echo " -c, --commit Git commit hash" + echo " -m, --message Git commit message" + echo " -d, --debug Debug mode enabled" + echo " -e, --env List of environment variables in the form of key1:value1,key2:value2" + echo " -h, --help Print this help text" + echo " -prid, --pull-request-id ID of the pull request." + echo " -pra, --pull-request-author Author of the pull request" + echo " -prhb, --pull-request-head-branch Head branch of the pull request (feature)" + echo " -prmb, --pull-request-merge-branch Merge branch of the pull request (feature)" + echo " -prru, --pull-request-repository-url URL of the repository of the pull request" + echo " -p, --poll Polling interval (in seconds) to get the build status." + echo " --stream Stream build logs" + echo " -s, --slug Bitrise project slug" + echo " -T, --test Test mode enabled" + echo " -t, --tag Git tag" + echo " -v, --version App version" + echo " -w, --workflow Bitrise workflow" echo } @@ -51,6 +58,10 @@ while [ $# -gt 0 ]; do -c|--commit) COMMIT="$2" shift;shift + ;; + -m|--message) + MESSAGE="$2" + shift;shift ;; -t|--tag) TAG="$2" @@ -60,6 +71,10 @@ while [ $# -gt 0 ]; do BRANCH="$2" shift;shift ;; + -bd|--branch-dest) + BRANCH_DEST="$2" + shift;shift + ;; -a|--access-token) ACCESS_TOKEN="$2" shift;shift @@ -88,6 +103,26 @@ while [ $# -gt 0 ]; do STREAM="true" shift ;; + -prid|--pull-request-id) + PULL_REQUEST_ID="$2" + shift;shift + ;; + -pra|--pull-request-author) + PULL_REQUEST_AUTHOR="$2" + shift;shift + ;; + -prhb|--pull-request-head-branch) + PULL_REQUEST_HEAD_BRANCH="$2" + shift;shift + ;; + -prmb|--pull-request-merge-branch) + PULL_REQUEST_MERGE_BRANCH="$2" + shift;shift + ;; + -prru|--pull-request-repository-url) + PULL_REQUEST_REPOSITORY_URL="$2" + shift;shift + ;; -p|--poll) STATUS_POLLING_INTERVAL="$2" shift;shift @@ -118,9 +153,7 @@ function validate_input() { [[ -n "$COMMIT" ]] && ((count++)) [[ -n "$BRANCH" ]] && ((count++)) - if [[ $count -gt 1 ]]; then - printf "\n\e[33m Warning: Too many building arguments passed. Only one of these is needed: --commit, --tag, --branch \e[0m\n" - elif [[ $count == 0 ]]; then + if [[ $count == 0 ]]; then printf "\e[31m ERROR: Missing build argument. Pass one of these: --commit, --tag, --branch\e[0m\n" usage exit 1 @@ -167,9 +200,16 @@ function generate_build_payload() { { "build_params": { "branch": "$BRANCH", + "branch_dest": "$BRANCH_DEST", "commit_hash": "$COMMIT", + "commit_message": "$MESSAGE", "tag": "$TAG", - "workflow_id" : "$WORKFLOW", + "workflow_id": "$WORKFLOW", + "pull_request_id": "$PULL_REQUEST_ID", + "pull_request_author": "$PULL_REQUEST_AUTHOR", + "pull_request_head_branch": "$PULL_REQUEST_HEAD_BRANCH", + "pull_request_merge_branch": "$PULL_REQUEST_MERGE_BRANCH", + "pull_request_repository_url": "$PULL_REQUEST_REPOSITORY_URL", "environments": $environments }, "hook_info": { @@ -193,7 +233,7 @@ function trigger_build() { status=$(echo "$response" | jq ".status" | sed 's/"//g' ) if [ "$status" != "ok" ]; then - msg=$(echo "$response" | jq ".message" | sed 's/"//g') + msg=$(echo "$response" | jq ".error_msg" | sed 's/"//g') printf "%s" "ERROR: $msg" exit 1 else