How to force refresh tags in commit view after post-receive hook?

I create a simple bash post-receive hook which adds tag to last commit. Hook is working because:

1. I can fetch created tags to my local repo,

2. I can see created tags on revision selector(branch, tags)

3. I can see tags when I request to the Bitbucket API

Unfortunately I cannot see this tags on commits view. It seems that the commits view is not refreshed. The funny thing is, when I add tag from view (go to commit and manually click "add tag") the not refreshed tags from my hook are appear. So, is there some possibility to force refresh the tags in the commit view after post receive hook executed?

1 answer

0 vote
Jeff Thomas Atlassian Team Sep 07, 2017

Hi,

Can you provide the post-receive hook that you're using so I can try to reproduce the problem locally?

Also, please confirm the version of Bitbucket Server that you're running.

Cheers,

Jeff

#!/usr/bin/env bash

CURRENT_COMMIT=$(git rev-parse --short HEAD)
CURRENT_TAG=$(git tag --points-at ${CURRENT_COMMIT})
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)

if [ ${BRANCH_NAME} = 'master' ]; then
    if [ -n "$CURRENT_TAG" ]; then
        echo "Current tag is: $CURRENT_TAG"
    else
        LAST_TAG_COMMIT=$(git rev-list --tags --max-count=1)
        LAST_TAGS=$(git tag --points-at ${LAST_TAG_COMMIT})

        IFS=' ' read -r -a array <<< ${LAST_TAGS}

        for i in "${array[@]}"
        do
            if [ -n "$i" -a -z "${i/v[0-9]*.[0-9]*.[0-9]*}" ] ; then
                LAST_TAG=${i}
            fi
        done

        if [ -n "$LAST_TAG" ]; then
            VERSION=`echo ${LAST_TAG} | sed "s/v//"`
            IFS='.' read -r -a array <<< ${VERSION}

            MAJOR="${array[0]}"
            MINOR="${array[1]}"
            PATCH="${array[2]}"

            MESSAGE=$(git log --format=%B -n 1 ${CURRENT_COMMIT} | xargs)
            CHOICE=`echo ${MESSAGE} | sed "s/.*\[\([^]]*\)\].*/\1/g"`

            case "$CHOICE" in
                "C") MAJOR=$(($MAJOR + 1))
                MINOR=0
                PATCH=0
                ;;
                "F") MINOR=$(($MINOR + 1))
                PATCH=0;;
                "B") PATCH=$(($PATCH + 1))
                ;;
                *) PATCH=$(($PATCH + 1))
                ;;
            esac

            NEW_VERSION=${MAJOR}.${MINOR}.${PATCH}
        else
            NEW_VERSION="0.0.1"
        fi

    NEW_TAG=v${NEW_VERSION}

    git tag -fa ${NEW_TAG} -m 'Release version ${NEW_VERSION}' ${CURRENT_COMMIT}
    echo "New tag created: $NEW_TAG at commit ${CURRENT_COMMIT}"

    fi
fi

 

 

BitBucket version v5.2.2

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,773 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you