Build status for Bitbucket Server

step
#1

Adding built in support for this was mentioned in Send status updates to hosted GitLab instances

@MartinStraub when we get to work on the built in support (meaning to do it without any Build Step) we’ll definitely support the self-hosted versions of the “big three” (GitHub, Bitbucket, GitLab).
Might take a bit more time for Bitbucket as the self hosted version of Bitbucket (Bitbucket Server) is quite a bit different compared to bitbucket.org, in fact it wasn’t even called Bitbucket initially, it was Atlassian Stash (https://www.atlassian.com/blog/archives/atlassian-stash-enterprise-git-repository-management), and even to this day these have separate API, webhook etc. formats, while GitHub and GitLab self-hosted have the same API & other formats as the .com hosted versions. In any case, a step for Bitbucket Server is definitely possible, similar to the existing GitHub Status (https://github.com/bitrise-steplib/steps-github-status) and GitLab Status (https://github.com/bitrise-steplib/steps-gitlab-status) steps. You can create a step if you have some time, it’s quite simple - a related recent blog post: https://blog.bitrise.io/how-to-create-and-share-your-own-bitrise-step

I just wanted to create a new feature request for this so it’s tracked. Are there any updates on this?

0 Likes

Add Support For Bitbucket Build Status
#2

No updates yet unfortunately, thanks for creating this #feature-request, we’ll update you here about the progress!

In the meantime the workaround is to use a Script step and call the related Bitbucket Server endpoint from that with e.g. curl.

0 Likes

#3

Thanks for the update.

Yeah, custom scripts are what we’re using now.

A script at the beginning to report progress:

- script@1.1.5:
        inputs:
        - content: |-
            #!/usr/bin/env bash

            curl https://$STASH_DOMAIN/rest/build-status/1.0/commits/$GIT_CLONE_COMMIT_HASH \
              -u $STASH_USER:$STASH_PASSWORD \
              -H 'Content-Type: application/json' \
              --data-binary \
              $'{
                "state": "INPROGRESS",
                "key": "Bitrise",
                "name": "Bitrise '$APP' #'$BITRISE_BUILD_NUMBER'",
                "url": "'$BITRISE_BUILD_URL'",
                "description": "'$BITRISE_TRIGGERED_WORKFLOW_ID' workflow"
               }' \
               --compressed
        title: Report build progress

And one at the end to report success or fail:

- script@1.1.5:
        is_always_run: true
        inputs:
        - content: |-
            #!/usr/bin/env bash

            if [ $BITRISE_BUILD_STATUS == "0" ]; then
              BUILD_STATE="SUCCESSFUL"
            else
              BUILD_STATE="FAILED"
            fi

            curl https://$STASH_DOMAIN/rest/build-status/1.0/commits/$GIT_CLONE_COMMIT_HASH \
              -u $STASH_USER:$STASH_PASSWORD \
              -H 'Content-Type: application/json' \
              --data-binary \
              $'{
                "state": "'$BUILD_STATE'",
                "key": "Bitrise",
                "name": "Bitrise '$APP' #'$BITRISE_BUILD_NUMBER'",
                "url": "'$BITRISE_BUILD_URL'",
                "description": "'$BITRISE_TRIGGERED_WORKFLOW_ID' workflow"
               }' \
               --compressed

It does mean we need STASH_USER and STASH_PASSWORD secrets

2 Likes

#4

Thanks for the scripts @yonas, I’m sure it’ll help others in the future, until we roll out the built in support for Bitbucket Server status reporting! :slight_smile:

0 Likes

#5

Thanks for the script @yonas ! I’ve adjusted it a bit and created a bitrise step from it! See https://github.com/teameh/bitrise-step-bitbucket-server-post-build-status/blob/master/step.sh

It works great, but when running it after my Fastlane step it will always be successful instead of failed when fastlane exists with an error. Any tips @viktorbenei?

0 Likes

#6

Hi @teameh! Could you please shoot us a build URL where you’re getting a false pass so we can have a think on this? Thanks!

0 Likes