Skip to content

Conversation

@henrygrant
Copy link

@henrygrant henrygrant commented Mar 6, 2023

Adds some additional parameters you can feed to the Bitrise API. These were necessary for more context in our Bitrise builds, and enabling auto-aborting of repeated builds to branches with open PRs.

I also removed the guard that requires only one of [branch|tag|commit] as params. Even though the documentation indicates you are only supposed to have one of these, the commit information still gets populated when you push a value for -b and -c.

This was an issue for my team, as we moved from webhooks to using Gitrise, but upon doing so and passing -b for the branch name, we lost commit context. This got it back for us.

Also, it seems like bitrise changed the key of the error message in the response object from message to error_msg. Addressed in this MR.

@henrygrant
Copy link
Author

Curious about what anyone else thinks about the non-mutual-exclucivity of tag, commit, and branch

@henrygrant henrygrant changed the title Feature: Add support for commit message Feature: Add support for commit message, Allow branch+commit+tag Mar 6, 2023
@henrygrant henrygrant changed the title Feature: Add support for commit message, Allow branch+commit+tag Feature: Add support for more fields, allow branch+commit+tag, fix error output Mar 14, 2023
"branch": "$BRANCH",
"branch_dest": "$BRANCH_DEST",
"commit_hash": "$COMMIT",
"commit_message": "$MESSAGE",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this implementation and this will not work when your commit message contains spaces. I changed the generate_build_payload() implementation so it used jq to create the payload.

function generate_build_payload() {
    local environments=$(process_env_vars "$ENV_STRING")
    jq -n --arg branch "$BRANCH" \
          --arg commit "$COMMIT" \
          --arg message "$MESSAGE" \
          --arg tag "$TAG" \
          --arg workflow "$WORKFLOW" \
          --argjson environments "$environments" \
    '{
        build_params: {
            branch: $branch,
            commit_hash: $commit,
            commit_message: $message,
            tag: $tag,
            workflow_id: $workflow,
            environments: $environments
        },
        hook_info: {
            type: "bitrise"
        }
    }'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants