Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Get the hash of the last commit or create a new empty commit using a bitbucket API Edited

Hello people, my question now is: I created a * sh to create a tag in another repository (weird thing I need more for my business rule to work in gcp) I'm doing this via the bitbucket api, only to create the precise hash tag for a commit from this repository, so far ok! But what I did is working, but of course it's not done well, but that's what I got for now.

#!/usr/bin/env bash

# Exit immediately if a any command exits with a non-zero status
set -e

# Set variables
echo "Get Last Commit"
curl$BITBUCKET_REPO_OWNER/$REPOSITORY/commits/?pagelen=1 \  
sed 's/{"pagelen.*, "hash//' arq1.hash > arq2.hash
grep -i "" arq2.hash | awk '{print $2}' > arq3.hash
sed 's/"//g' arq3.hash > arq4.hash
sed 's/,//g' arq4.hash > arq5.hash
LAST_COMMIT_HASH=$(cat arq5.hash)
rm -f arq*.hash
echo "Last Commit: " $LAST_COMMIT_HASH

# Create new tag
echo "Creating Tag"
--fail --show-error --silent \
-H 'Content-Type: application/json' \  
        "target": { 
               "hash": "

What I would like to know is if it is possible through the API to rescue the hash of the last commit from the master of a repository OR if I can create an empty commit (git commit --allow-empty) through the api and in return get this hash? !

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

2,589 views 1 9
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you